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