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
158}158}
159 159
160void ScriptEngine::runInThread() {160void 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
161 _isThreaded = true;168 _isThreaded = true;
162 QThread* workerThread = new QThread(); // thread is not owned, so we need to manage the delete169 QThread* workerThread = new QThread(); // thread is not owned, so we need to manage the delete
163 QString scriptEngineName = QString("Script Thread:") + getFilename();170 QString scriptEngineName = QString("Script Thread:") + getFilename();