Permalink
Browse files

Fix threading issue with runPythonScript. Refs #5206

It printed directly to the console to the method needs to be called from
the main thread.
  • Loading branch information...
1 parent e11e505 commit cc80ef78f2cbacbe9732431a44727f92991607e6 @martyngigg martyngigg committed May 2, 2012
Showing with 3 additions and 5 deletions.
  1. +3 −1 Code/Mantid/MantidPlot/mantidplot.py
  2. +0 −4 Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
@@ -46,7 +46,9 @@ def runPythonScript(code, async = False, quiet = False, redirect = True):
@param quiet :: If true no messages reporting status are issued
@param redirect :: If true then output is redirected to MantidPlot
"""
- _qti.app.runPythonScript(code, async, quiet, redirect)
+ if async and QtCore.QThread.currentThread() != QtGui.qApp.thread():
+ async = False
+ threadsafe_call(_qti.app.runPythonScript, code, async, quiet, redirect)
# Overload for consistency with qtiplot table(..) & matrix(..) commands
def workspace(name):
@@ -16531,10 +16531,6 @@ bool ApplicationWindow::runPythonScript(const QString & code, bool async,
}
bool success(false);
- if(QApplication::instance()->thread() != QThread::currentThread())
- {
- async = false;
- }
if(async)
{
QFuture<bool> job = m_iface_script->executeAsync(code);

0 comments on commit cc80ef7

Please sign in to comment.