History

simplify waitTillDoneRunning

ZappoMan committed 11 years ago

Commit f1017f81 parent 31065481 file · +6 −15Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+6−15
@@ -176,23 +176,14 @@ void ScriptEngine::waitTillDoneRunning() { · 175 unmodified lines
176176
177177 _doneRunningThisScript = false; // NOTE: this is static, we serialize our waiting for scripts to finish
178178
179− // What can we do here???
180− // we will be calling this on the main Application thread, inside of stopAllScripts()
181− // we want the application thread to continue to process events, because the script will
182− // likely need to marshall messages across to the main thread.
183− while (!_doneRunningThisScript && _isRunning) {
179+ // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts()
180+ // we want the application thread to continue to process events, because the scripts will likely need to
181+ // marshall messages across to the main thread. For example if they access Settings or Meny in any of their
182+ // shutdown code.
183+ while (!_doneRunningThisScript) {
184184
185− // and run a QEventLoop???
186− QEventLoop loop;
187− QObject::connect(this, &ScriptEngine::doneRunning, &loop, &QEventLoop::quit);
188− loop.exec();
189−
190− // process events
185+ // process events for the main application thread, allowing invokeMethod calls to pass between threads
191186 QCoreApplication::processEvents();
192−
193− if (_doneRunningThisScript) {
194− break;
195− }
196187 }
197188 }
198189 }