r16569 by jghali - fix scripter freezing after script execution when using python 2.7
scribus-commit
scribus-commit at lists.scribus.net
Mon Apr 11 00:33:45 CEST 2011
Author: jghali
Date: Sun Apr 10 22:33:45 2011
New Revision: 16569
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16569
Log:
fix scripter freezing after script execution when using python 2.7
Modified:
branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
Modified: branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16569&path=/branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Sun Apr 10 22:33:45 2011
@@ -257,11 +257,11 @@
void ScripterCore::slotRunScriptFile(QString fileName, bool inMainInterpreter)
{
- PyThreadState *stateo = NULL;
PyThreadState *state = NULL;
QFileInfo fi(fileName);
QByteArray na = fi.fileName().toLocal8Bit();
// Set up a sub-interpreter if needed:
+ PyThreadState* global_state = NULL;
if (!inMainInterpreter)
{
ScCore->primaryMainWindow()->propertiesPalette->unsetDoc();
@@ -270,7 +270,8 @@
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
// Create the sub-interpreter
// FIXME: This calls abort() in a Python debug build. We're doing something wrong.
- stateo = PyEval_SaveThread();
+ //stateo = PyEval_SaveThread();
+ global_state = PyThreadState_Get();
state = Py_NewInterpreter();
// Chdir to the dir the script is in
QDir::setCurrent(fi.absolutePath());
@@ -369,7 +370,8 @@
if (!inMainInterpreter)
{
Py_EndInterpreter(state);
- PyEval_RestoreThread(stateo);
+ PyThreadState_Swap(global_state);
+ //PyEval_RestoreThread(stateo);
// qApp->restoreOverrideCursor();
ScCore->primaryMainWindow()->setScriptRunning(false);
}
More information about the scribus-commit
mailing list