Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -176,23 +176,14 @@ void ScriptEngine::waitTillDoneRunning() { · 175 unmodified lines | ||
| 176 | 176 | |
| 177 | 177 | _doneRunningThisScript = false; // NOTE: this is static, we serialize our waiting for scripts to finish |
| 178 | 178 | |
| 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) { | |
| 184 | 184 | |
| 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 | |
| 191 | 186 | QCoreApplication::processEvents(); |
| 192 | − | |
| 193 | − if (_doneRunningThisScript) { | |
| 194 | − break; | |
| 195 | − } | |
| 196 | 187 | } |
| 197 | 188 | } |
| 198 | 189 | } |