Fix script engine deletion
Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -170,7 +170,7 @@ void ScriptEngine::runInThread() { · 169 unmodified lines | ||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | _isThreaded = true; |
| 173 | − QThread* workerThread = new QThread(); // thread is not owned, so we need to manage the delete | |
| 173 | + QThread* workerThread = new QThread(this); // thread is not owned, so we need to manage the delete | |
| 174 | 174 | QString scriptEngineName = QString("Script Thread:") + getFilename(); |
| 175 | 175 | workerThread->setObjectName(scriptEngineName); |
| 176 | 176 | |
| @@ -184,9 +184,6 @@ void ScriptEngine::runInThread() { · 7 unmodified lines | ||
| 184 | 184 | // tell the thread to stop when the script engine is done |
| 185 | 185 | connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit); |
| 186 | 186 | |
| 187 | − // when the thread is finished, add thread to the deleteLater queue | |
| 188 | − connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater); | |
| 189 | − | |
| 190 | 187 | moveToThread(workerThread); |
| 191 | 188 | |
| 192 | 189 | // Starts an event loop, and emits workerThread->started() |
| @@ -199,7 +196,7 @@ void ScriptEngine::waitTillDoneRunning() { · 6 unmodified lines | ||
| 199 | 196 | |
| 200 | 197 | // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts() |
| 201 | 198 | // we want the application thread to continue to process events, because the scripts will likely need to |
| 202 | − // marshall messages across to the main thread. For example if they access Settings or Meny in any of their | |
| 199 | + // marshall messages across to the main thread. For example if they access Settings or Menu in any of their | |
| 203 | 200 | // shutdown code. |
| 204 | 201 | while (thread()->isRunning()) { |
| 205 | 202 | // process events for the main application thread, allowing invokeMethod calls to pass between threads |