mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-13 21:27:21 +02:00
Merge pull request #15322 from huffman/fix/interactive-window-shutdown-crash
Case 18299: Fix ScriptEngine not being destroyed on its own thread
This commit is contained in:
commit
b9c81a3899
1 changed files with 3 additions and 3 deletions
|
@ -163,7 +163,7 @@ ScriptEnginePointer scriptEngineFactory(ScriptEngine::Context context,
|
|||
const QString& scriptContents,
|
||||
const QString& fileNameString) {
|
||||
ScriptEngine* engine = new ScriptEngine(context, scriptContents, fileNameString);
|
||||
ScriptEnginePointer engineSP = ScriptEnginePointer(engine);
|
||||
ScriptEnginePointer engineSP = ScriptEnginePointer(engine, &QObject::deleteLater);
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
scriptEngines->addScriptEngine(qSharedPointerCast<ScriptEngine>(engineSP));
|
||||
engine->setScriptEngines(scriptEngines);
|
||||
|
@ -267,7 +267,7 @@ void ScriptEngine::disconnectNonEssentialSignals() {
|
|||
QThread* workerThread;
|
||||
// Ensure the thread should be running, and does exist
|
||||
if (_isRunning && _isThreaded && (workerThread = thread())) {
|
||||
connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
|
||||
connect(this, &QObject::destroyed, workerThread, &QThread::quit);
|
||||
connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ void ScriptEngine::runInThread() {
|
|||
// the script engine, make sure to add code to "reconnect" them to the
|
||||
// disconnectNonEssentialSignals() method
|
||||
connect(workerThread, &QThread::started, this, &ScriptEngine::run);
|
||||
connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
|
||||
connect(this, &QObject::destroyed, workerThread, &QThread::quit);
|
||||
connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);
|
||||
|
||||
workerThread->start();
|
||||
|
|
Loading…
Reference in a new issue