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
140 connect(this, &QScriptEngine::signalHandlerException, this, [this](const QScriptValue& exception) {140 connect(this, &QScriptEngine::signalHandlerException, this, [this](const QScriptValue& exception) {
141 hadUncaughtExceptions(*this, _fileNameString);141 hadUncaughtExceptions(*this, _fileNameString);
142 });142 });
143
144 setProcessEventsInterval(MSECS_PER_SECOND);
143}145}
144 146
145ScriptEngine::~ScriptEngine() {147ScriptEngine::~ScriptEngine() {
@@ -193,6 +195,14 @@ void ScriptEngine::runInThread() { · 47 unmodified lines
193 workerThread->start();195 workerThread->start();
194}196}
195 197
198void ScriptEngine::threadSafeAbortEvaluation() {
199 if (QThread::currentThread() != thread()) {
200 QMetaObject::invokeMethod(this, "threadSafeAbortEvaluation");
201 return;
202 }
203 abortEvaluation();
204}
205
196void ScriptEngine::waitTillDoneRunning() {206void ScriptEngine::waitTillDoneRunning() {
197 // If the script never started running or finished running before we got here, we don't need to wait for it207 // If the script never started running or finished running before we got here, we don't need to wait for it
198 if (_isRunning && _isThreaded) {208 if (_isRunning && _isThreaded) {
@@ -213,7 +223,7 @@ void ScriptEngine::waitTillDoneRunning() { · 14 unmodified lines
213 // if we've been waiting a second or more, then tell the script engine to stop evaluating223 // if we've been waiting a second or more, then tell the script engine to stop evaluating
214 if (elapsed > USECS_PER_SECOND) {224 if (elapsed > USECS_PER_SECOND) {
215 qDebug() << "giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;225 qDebug() << "giving up on evaluation elapsed:" << elapsed << "calling abortEvaluation() script:" << scriptName;
216 abortEvaluation();226 threadSafeAbortEvaluation();
217 }227 }
218 228
219 // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping229 // if we've been waiting for more than 5 seconds then we should be more aggessive about stopping