r16570 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:34:08 CEST 2011


Author: jghali
Date: Sun Apr 10 22:34:08 2011
New Revision: 16570

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16570
Log:
fix scripter freezing after script execution when using python 2.7

Modified:
    trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16570&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Sun Apr 10 22:34:08 2011
@@ -223,11 +223,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();
@@ -236,7 +236,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());
@@ -335,7 +336,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