History

Merge pull request #7783 from zzmp/fix/script-engine-deletion

Fix script engine deletion

Brad Hefta-Gaub committed 10 years ago

Commit 2b548132 parents 49d02b8 30e7b951 file · +2 −5Browse 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−5
@@ -170,7 +170,7 @@ void ScriptEngine::runInThread() { · 169 unmodified lines
170 }170 }
171 171
172 _isThreaded = true;172 _isThreaded = true;
173 QThread* workerThread = new QThread(); // thread is not owned, so we need to manage the delete173 QThread* workerThread = new QThread(this); // thread is not owned, so we need to manage the delete
174 QString scriptEngineName = QString("Script Thread:") + getFilename();174 QString scriptEngineName = QString("Script Thread:") + getFilename();
175 workerThread->setObjectName(scriptEngineName);175 workerThread->setObjectName(scriptEngineName);
176 176
@@ -184,9 +184,6 @@ void ScriptEngine::runInThread() { · 7 unmodified lines
184 // tell the thread to stop when the script engine is done184 // tell the thread to stop when the script engine is done
185 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);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 moveToThread(workerThread);187 moveToThread(workerThread);
191 188
192 // Starts an event loop, and emits workerThread->started()189 // Starts an event loop, and emits workerThread->started()
@@ -199,7 +196,7 @@ void ScriptEngine::waitTillDoneRunning() { · 6 unmodified lines
199 196
200 // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts()197 // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts()
201 // we want the application thread to continue to process events, because the scripts will likely need to198 // 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 their199 // marshall messages across to the main thread. For example if they access Settings or Menu in any of their
203 // shutdown code.200 // shutdown code.
204 while (thread()->isRunning()) {201 while (thread()->isRunning()) {
205 // process events for the main application thread, allowing invokeMethod calls to pass between threads202 // process events for the main application thread, allowing invokeMethod calls to pass between threads