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
231 // Ensure the thread should be running, and does exist231 // Ensure the thread should be running, and does exist
232 if (_isRunning && _isThreaded && (workerThread = thread())) {232 if (_isRunning && _isThreaded && (workerThread = thread())) {
233 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);233 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
234 connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);234 connect(this, &QObject::destroyed, workerThread, &QObject::deleteLater);
235 }235 }
236}236}
237 237
@@ -346,7 +346,7 @@ void ScriptEngine::runInThread() { · 108 unmodified lines
346 // disconnectNonEssentialSignals() method346 // disconnectNonEssentialSignals() method
347 connect(workerThread, &QThread::started, this, &ScriptEngine::run);347 connect(workerThread, &QThread::started, this, &ScriptEngine::run);
348 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);348 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
349 connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);349 connect(this, &QObject::destroyed, workerThread, &QObject::deleteLater);
350 350
351 workerThread->start();351 workerThread->start();
352}352}