History

some CR feedback

ZappoMan committed 10 years ago

Commit 73ff0301 parent 48e63ea2 files · +12 −1Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+11−1
@@ -140,6 +140,8 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 139 unmodified lines
140140 connect(this, &QScriptEngine::signalHandlerException, this, [this](const QScriptValue& exception) {
141141 hadUncaughtExceptions(*this, _fileNameString);
142142 });
143+
144+ setProcessEventsInterval(MSECS_PER_SECOND);
143145 }
144146
145147 ScriptEngine::~ScriptEngine() {
@@ -193,6 +195,14 @@ void ScriptEngine::runInThread() { · 47 unmodified lines
193195 workerThread->start();
194196 }
195197
198+void ScriptEngine::threadSafeAbortEvaluation() {
199+ if (QThread::currentThread() != thread()) {
200+ QMetaObject::invokeMethod(this, "threadSafeAbortEvaluation");
201+ return;
202+ }
203+ abortEvaluation();
204+}
205+
196206 void ScriptEngine::waitTillDoneRunning() {
197207 // If the script never started running or finished running before we got here, we don't need to wait for it
198208 if (_isRunning && _isThreaded) {
@@ -213,7 +223,7 @@ void ScriptEngine::waitTillDoneRunning() { · 14 unmodified lines
213223 // if we've been waiting a second or more, then tell the script engine to stop evaluating
214224 if (elapsed > USECS_PER_SECOND) {
215225 qDebug() << "giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;
216− abortEvaluation();
226+ threadSafeAbortEvaluation();
217227 }
218228
219229 // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping