History

more CR feedback

Brad Hefta-Gaub committed 10 years ago

Commit 45690321 parent 6026e052 files · +7 −17Browse 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+7−16
@@ -195,14 +195,6 @@ void ScriptEngine::runInThread() { · 194 unmodified lines
195195 workerThread->start();
196196 }
197197
198−void ScriptEngine::threadSafeAbortEvaluation() {
199− if (QThread::currentThread() != thread()) {
200− QMetaObject::invokeMethod(this, "threadSafeAbortEvaluation");
201− return;
202− }
203− abortEvaluation();
204−}
205−
206198 void ScriptEngine::waitTillDoneRunning() {
207199 // If the script never started running or finished running before we got here, we don't need to wait for it
208200 if (_isRunning && _isThreaded) {
@@ -218,21 +210,20 @@ void ScriptEngine::waitTillDoneRunning() { · 9 unmodified lines
218210 // process events for the main application thread, allowing invokeMethod calls to pass between threads
219211 QCoreApplication::processEvents();
220212 auto stillWaiting = usecTimestampNow();
221− auto elapsed = stillWaiting - startedWaiting;
213+ auto elapsedUsecs = stillWaiting - startedWaiting;
222214
223215 // if we've been waiting a second or more, then tell the script engine to stop evaluating
224216 static const auto MAX_SCRIPT_EVALUATION_TIME = USECS_PER_SECOND;
225− if (elapsed > MAX_SCRIPT_EVALUATION_TIME) {
226− qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsed << "] aborting evaluation.";
227− threadSafeAbortEvaluation();
228− }
217+ static const auto WAITING_TOO_LONG = MAX_SCRIPT_EVALUATION_TIME * 5;
229218
230219 // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping
231− static const auto WAITING_TOO_LONG = USECS_PER_SECOND * 5;
232− if (elapsed > WAITING_TOO_LONG) {
233− qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsed << "] quitting.";
220+ if (elapsedUsecs > WAITING_TOO_LONG) {
221+ qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsedUsecs << "] quitting.";
234222 thread()->quit();
235223 break;
224+ } else if (elapsedUsecs > MAX_SCRIPT_EVALUATION_TIME) {
225+ qCDebug(scriptengine) << "Script " << scriptName << " has been running too long [" << elapsedUsecs << "] aborting evaluation.";
226+ QMetaObject::invokeMethod(this, "abortEvaluation");
236227 }
237228 }
238229 }