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
176 176
177 _doneRunningThisScript = false; // NOTE: this is static, we serialize our waiting for scripts to finish177 _doneRunningThisScript = false; // NOTE: this is static, we serialize our waiting for scripts to finish
178 178
179 // What can we do here???179 // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts()
180 // we will be calling this 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 // we want the application thread to continue to process events, because the script will181 // marshall messages across to the main thread. For example if they access Settings or Meny in any of their
182 // likely need to marshall messages across to the main thread.182 // shutdown code.
183 while (!_doneRunningThisScript && _isRunning) {183 while (!_doneRunningThisScript) {
184 184
185 // and run a QEventLoop???185 // process events for the main application thread, allowing invokeMethod calls to pass between threads
186 QEventLoop loop;
187 QObject::connect(this, &ScriptEngine::doneRunning, &loop, &QEventLoop::quit);
188 loop.exec();
189
190 // process events
191 QCoreApplication::processEvents();186 QCoreApplication::processEvents();
192
193 if (_doneRunningThisScript) {
194 break;
195 }
196 }187 }
197 }188 }
198}189}