Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -154,7 +154,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 153 unmodified lines | ||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | ScriptEngine::~ScriptEngine() { |
| 157 | − qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename(); | |
| 157 | + qCDebug(scriptengine) << "Script Engine shutting down:" << getFilename(); | |
| 158 | 158 | |
| 159 | 159 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); |
| 160 | 160 | if (scriptEngines) { |
| @@ -291,11 +291,10 @@ void ScriptEngine::wait() { · 130 unmodified lines | ||
| 291 | 291 | // We should never be waiting (blocking) on our own thread |
| 292 | 292 | assert(workerThread != QThread::currentThread()); |
| 293 | 293 | |
| 294 | + // Engine should be stopped already, but be defensive | |
| 294 | 295 | stop(); |
| 295 | 296 | |
| 296 | − QString scriptName = getFilename(); | |
| 297 | 297 | auto startedWaiting = usecTimestampNow(); |
| 298 | − | |
| 299 | 298 | while (workerThread->isRunning()) { |
| 300 | 299 | // NOTE: This will be called on the main application thread from stopAllScripts. |
| 301 | 300 | // The application thread will need to continue to process events, because |
| @@ -310,13 +309,13 @@ void ScriptEngine::wait() { · 8 unmodified lines | ||
| 310 | 309 | auto elapsedUsecs = usecTimestampNow() - startedWaiting; |
| 311 | 310 | if (elapsedUsecs > MAX_SCRIPT_EVALUATION_TIME) { |
| 312 | 311 | qCDebug(scriptengine).nospace() << |
| 313 | − "Script " << scriptName << " has been running too long [" << elapsedUsecs << "usecs] quitting."; | |
| 312 | + "Script Engine has been running too long, aborting:" << getFilename(); | |
| 314 | 313 | abortEvaluation(); // break out of current evaluation |
| 315 | 314 | |
| 316 | 315 | // Wait for the scripting thread to stop running |
| 317 | 316 | if (!workerThread->wait(MAX_SCRIPT_QUITTING_TIME)) { |
| 318 | 317 | qCWarning(scriptengine).nospace() << |
| 319 | − "Script " << scriptName << " has been quitting too long [" << elapsedUsecs << "usecs] terminating."; | |
| 318 | + "Script Engine has been aborting too long, terminating:" << getFilename(); | |
| 320 | 319 | workerThread->terminate(); |
| 321 | 320 | } |
| 322 | 321 | } |
| @@ -324,6 +323,8 @@ void ScriptEngine::wait() { · 1 unmodified line | ||
| 324 | 323 | // Avoid a pure busy wait |
| 325 | 324 | QThread::yieldCurrentThread(); |
| 326 | 325 | } |
| 326 | + | |
| 327 | + qCDebug(scriptengine) << "Script Engine has stopped:" << getFilename(); | |
| 327 | 328 | } |
| 328 | 329 | } |
| 329 | 330 | |
| @@ -874,6 +875,8 @@ void ScriptEngine::run() { · 544 unmodified lines | ||
| 874 | 875 | hadUncaughtExceptions(*this, _fileNameString); |
| 875 | 876 | } |
| 876 | 877 | |
| 878 | + qCDebug(scriptengine) << "Script Engine stopping:" << getFilename(); | |
| 879 | + | |
| 877 | 880 | stopAllTimers(); // make sure all our timers are stopped if the script is ending |
| 878 | 881 | emit scriptEnding(); |
| 879 | 882 | |