History

Fix ScriptEngine thread being deleted too early

The thread appeared to be deleted before waitTillDoneRunning was finished. This is a speculative fix. This ensures that the QThread isn't deleted until after the ScriptEngine is deleted.

Ryan Huffman committed 9 years ago

Commit 09c98b31 parent bfb44691 file · +2 −2Browse 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+2−2
@@ -231,7 +231,7 @@ void ScriptEngine::disconnectNonEssentialSignals() { · 230 unmodified lines
231231 // Ensure the thread should be running, and does exist
232232 if (_isRunning && _isThreaded && (workerThread = thread())) {
233233 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
234− connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);
234+ connect(this, &QObject::destroyed, workerThread, &QObject::deleteLater);
235235 }
236236 }
237237
@@ -346,7 +346,7 @@ void ScriptEngine::runInThread() { · 108 unmodified lines
346346 // disconnectNonEssentialSignals() method
347347 connect(workerThread, &QThread::started, this, &ScriptEngine::run);
348348 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
349− connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);
349+ connect(this, &QObject::destroyed, workerThread, &QObject::deleteLater);
350350
351351 workerThread->start();
352352 }