Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -163,7 +163,7 @@ ScriptEnginePointer scriptEngineFactory(ScriptEngine::Context context, · 162 unmodified lines | ||
| 163 | 163 | const QString& scriptContents, |
| 164 | 164 | const QString& fileNameString) { |
| 165 | 165 | ScriptEngine* engine = new ScriptEngine(context, scriptContents, fileNameString); |
| 166 | − ScriptEnginePointer engineSP = ScriptEnginePointer(engine); | |
| 166 | + ScriptEnginePointer engineSP = ScriptEnginePointer(engine, &QObject::deleteLater); | |
| 167 | 167 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); |
| 168 | 168 | scriptEngines->addScriptEngine(qSharedPointerCast<ScriptEngine>(engineSP)); |
| 169 | 169 | engine->setScriptEngines(scriptEngines); |
| @@ -267,7 +267,7 @@ void ScriptEngine::disconnectNonEssentialSignals() { · 97 unmodified lines | ||
| 267 | 267 | QThread* workerThread; |
| 268 | 268 | // Ensure the thread should be running, and does exist |
| 269 | 269 | if (_isRunning && _isThreaded && (workerThread = thread())) { |
| 270 | − connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit); | |
| 270 | + connect(this, &QObject::destroyed, workerThread, &QThread::quit); | |
| 271 | 271 | connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater); |
| 272 | 272 | } |
| 273 | 273 | } |
| @@ -381,7 +381,7 @@ void ScriptEngine::runInThread() { · 107 unmodified lines | ||
| 381 | 381 | // the script engine, make sure to add code to "reconnect" them to the |
| 382 | 382 | // disconnectNonEssentialSignals() method |
| 383 | 383 | connect(workerThread, &QThread::started, this, &ScriptEngine::run); |
| 384 | − connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit); | |
| 384 | + connect(this, &QObject::destroyed, workerThread, &QThread::quit); | |
| 385 | 385 | connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater); |
| 386 | 386 | |
| 387 | 387 | workerThread->start(); |