r17680 by jghali - #10804: Scribus crash opening 2 script at the same time
scribus-commit
scribus-commit at lists.scribus.net
Wed Jul 4 20:21:29 UTC 2012
Author: jghali
Date: Wed Jul 4 20:21:28 2012
New Revision: 17680
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17680
Log:
#10804: Scribus crash opening 2 script at the same time
Modified:
branches/Version14x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.h
Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17680&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/pconsole.cpp Wed Jul 4 20:21:28 2012
@@ -14,12 +14,13 @@
#include "pconsole.h"
#include <QFileDialog>
-#include "scribus.h"
+#include "commonstrings.h"
#include "prefsmanager.h"
#include "prefsfile.h"
#include "prefscontext.h"
#include "scmessagebox.h"
-#include "commonstrings.h"
+#include "scribus.h"
+#include "scribuscore.h"
#include "util_icon.h"
@@ -125,6 +126,15 @@
void PythonConsole::slot_runScript()
{
outputEdit->clear();
+
+ //Prevent two scripts to be run concurrently or face crash!
+ if (ScCore->primaryMainWindow()->scriptIsRunning())
+ {
+ outputEdit->append( tr("Another script is already running...") );
+ outputEdit->append( tr("Please let it finish its task...") );
+ return;
+ }
+
parsePythonString();
emit runCommand();
commandEdit->textCursor().movePosition(QTextCursor::Start);
@@ -132,6 +142,14 @@
void PythonConsole::slot_runScriptAsConsole()
{
+ //Prevent two scripts to be run concurrently or face crash!
+ if (ScCore->primaryMainWindow()->scriptIsRunning())
+ {
+ outputEdit->append( tr("\n>>> Another script is already running...") );
+ outputEdit->append( tr("Please let it finish its task...") );
+ return;
+ }
+
parsePythonString();
commandEdit->clear();
// content is destroyed. This is to prevent overwriting
Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17680&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Wed Jul 4 20:21:28 2012
@@ -35,6 +35,8 @@
ScripterCore::ScripterCore(QWidget* parent)
{
+ menuMgr = NULL;
+
pcon = new PythonConsole(parent);
scrScripterActions.clear();
scrRecentScriptActions.clear();
@@ -83,6 +85,23 @@
buildRecentScriptsMenu();
}
+void ScripterCore::enableMainWindowMenu()
+{
+ if (!menuMgr)
+ return;
+ menuMgr->setMenuEnabled("ScribusScripts", true);
+ menuMgr->setMenuEnabled("RecentScripts", true);
+ scrScripterActions["scripterExecuteScript"]->setEnabled(true);
+}
+
+void ScripterCore::disableMainWindowMenu()
+{
+ if (!menuMgr)
+ return;
+ menuMgr->setMenuEnabled("ScribusScripts", false);
+ menuMgr->setMenuEnabled("RecentScripts", false);
+ scrScripterActions["scripterExecuteScript"]->setEnabled(false);
+}
void ScripterCore::buildScribusScriptsMenu()
{
@@ -257,6 +276,11 @@
void ScripterCore::slotRunScriptFile(QString fileName, bool inMainInterpreter)
{
+ // Prevent two scripts to be run concurrently or face crash!
+ if (ScCore->primaryMainWindow()->scriptIsRunning())
+ return;
+ disableMainWindowMenu();
+
PyThreadState *state = NULL;
QFileInfo fi(fileName);
QByteArray na = fi.fileName().toLocal8Bit();
@@ -376,10 +400,17 @@
// qApp->restoreOverrideCursor();
ScCore->primaryMainWindow()->setScriptRunning(false);
}
+
+ enableMainWindowMenu();
}
void ScripterCore::slotRunScript(const QString Script)
{
+ // Prevent two scripts to be run concurrently or face crash!
+ if (ScCore->primaryMainWindow()->scriptIsRunning())
+ return;
+ disableMainWindowMenu();
+
ScCore->primaryMainWindow()->propertiesPalette->unsetDoc();
ScCore->primaryMainWindow()->pagePalette->setView(NULL);
ScCore->primaryMainWindow()->setScriptRunning(true);
@@ -446,6 +477,8 @@
Py_XDECREF(result);
}
ScCore->primaryMainWindow()->setScriptRunning(false);
+
+ enableMainWindowMenu();
}
void ScripterCore::slotInteractiveScript(bool visible)
Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17680&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.h
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.h (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/scriptercore.h Wed Jul 4 20:21:28 2012
@@ -24,7 +24,10 @@
public:
ScripterCore(QWidget* parent);
~ScripterCore();
+
void addToMainWindowMenu(ScribusMainWindow *);
+ void enableMainWindowMenu();
+ void disableMainWindowMenu();
/** @brief String representation of result returned by last python console command */
QString returnString;
More information about the scribus-commit
mailing list