Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -397,15 +397,20 @@ void ScriptEngine::executeOnScriptThread(std::function<void()> function, const Q · 396 unmodified lines | |||
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | void ScriptEngine::waitTillDoneRunning() { | 399 | void ScriptEngine::waitTillDoneRunning() { |
| 400 | // Engine should be stopped already, but be defensive | ||
| 401 | stop(); | ||
| 402 | |||
| 400 | auto workerThread = thread(); | 403 | auto workerThread = thread(); |
| 401 | 404 | ||
| 405 | if (workerThread == QThread::currentThread()) { | ||
| 406 | qCWarning(scriptengine) << "ScriptEngine::waitTillDoneRunning called, but the script is on the same thread:" << getFilename(); | ||
| 407 | return; | ||
| 408 | } | ||
| 409 | |||
| 402 | if (_isThreaded && workerThread) { | 410 | if (_isThreaded && workerThread) { |
| 403 | // We should never be waiting (blocking) on our own thread | 411 | // We should never be waiting (blocking) on our own thread |
| 404 | assert(workerThread != QThread::currentThread()); | 412 | assert(workerThread != QThread::currentThread()); |
| 405 | 413 | ||
| 406 | // Engine should be stopped already, but be defensive | ||
| 407 | stop(); | ||
| 408 | |||
| 409 | auto startedWaiting = usecTimestampNow(); | 414 | auto startedWaiting = usecTimestampNow(); |
| 410 | while (workerThread->isRunning()) { | 415 | while (workerThread->isRunning()) { |
| 411 | // If the final evaluation takes too long, then tell the script engine to stop running | 416 | // If the final evaluation takes too long, then tell the script engine to stop running |