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
170170 }
171171
172172 _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
174174 QString scriptEngineName = QString("Script Thread:") + getFilename();
175175 workerThread->setObjectName(scriptEngineName);
176176
@@ -184,9 +184,6 @@ void ScriptEngine::runInThread() { · 7 unmodified lines
184184 // tell the thread to stop when the script engine is done
185185 connect(this, &ScriptEngine::doneRunning, workerThread, &QThread::quit);
186186
187− // when the thread is finished, add thread to the deleteLater queue
188− connect(workerThread, &QThread::finished, workerThread, &QThread::deleteLater);
189−
190187 moveToThread(workerThread);
191188
192189 // Starts an event loop, and emits workerThread->started()
@@ -199,7 +196,7 @@ void ScriptEngine::waitTillDoneRunning() { · 6 unmodified lines
199196
200197 // NOTE: waitTillDoneRunning() will be called on the main Application thread, inside of stopAllScripts()
201198 // 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
203200 // shutdown code.
204201 while (thread()->isRunning()) {
205202 // process events for the main application thread, allowing invokeMethod calls to pass between threads