History

Add protection around ScriptEngine::runInThread being called twice

Ryan Huffman committed 10 years ago

Commit 1a2f74f1 parent 6b3a4eb1 file · +7 −0Browse 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+7−0
@@ -158,6 +158,13 @@ void ScriptEngine::disconnectNonEssentialSignals() { · 157 unmodified lines
158158 }
159159
160160 void ScriptEngine::runInThread() {
161+ Q_ASSERT_X(!_isThreaded, "ScriptEngine::runInThread()", "runInThread should not be called more than once");
162+
163+ if (_isThreaded) {
164+ qCWarning(scriptengine) << "ScriptEngine already running in thread: " << getFilename();
165+ return;
166+ }
167+
161168 _isThreaded = true;
162169 QThread* workerThread = new QThread(); // thread is not owned, so we need to manage the delete
163170 QString scriptEngineName = QString("Script Thread:") + getFilename();