mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 22:09:02 +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& scriptContents,
|
||||||
const QString& fileNameString) {
|
const QString& fileNameString) {
|
||||||
ScriptEngine* engine = new ScriptEngine(context, scriptContents, fileNameString);
|
ScriptEngine* engine = new ScriptEngine(context, scriptContents, fileNameString);
|
||||||
ScriptEnginePointer engineSP = ScriptEnginePointer(engine);
|
ScriptEnginePointer engineSP = ScriptEnginePointer(engine, &QObject::deleteLater);
|
||||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||||
scriptEngines->addScriptEngine(qSharedPointerCast<ScriptEngine>(engineSP));
|
scriptEngines->addScriptEngine(qSharedPointerCast<ScriptEngine>(engineSP));
|
||||||
engine->setScriptEngines(scriptEngines);
|
engine->setScriptEngines(scriptEngines);
|
||||||
|
@ -267,7 +267,7 @@ void ScriptEngine::disconnectNonEssentialSignals() {
|
||||||
QThread* workerThread;
|
QThread* workerThread;
|
||||||
// Ensure the thread should be running, and does exist
|
// Ensure the thread should be running, and does exist
|
||||||
if (_isRunning && _isThreaded && (workerThread = thread())) {
|
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);
|
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
|
// the script engine, make sure to add code to "reconnect" them to the
|
||||||
// disconnectNonEssentialSignals() method
|
// disconnectNonEssentialSignals() method
|
||||||
connect(workerThread, &QThread::started, this, &ScriptEngine::run);
|
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);
|
connect(workerThread, &QThread::finished, workerThread, &QObject::deleteLater);
|
||||||
|
|
||||||
workerThread->start();
|
workerThread->start();
|
||||||
|
|
Loading…
Reference in a new issue