Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 6 files). Show all
Unified · Split
| @@ -160,7 +160,7 @@ void ScriptEngines::shutdownScripting() { · 159 unmodified lines | |||
| 160 | scriptEngine->disconnect(this); | 160 | scriptEngine->disconnect(this); |
| 161 | 161 | ||
| 162 | // Gracefully stop the engine's scripting thread | 162 | // Gracefully stop the engine's scripting thread |
| 163 | scriptEngine->stop(false); | 163 | scriptEngine->stop(); |
| 164 | 164 | ||
| 165 | // We need to wait for the engine to be done running before we proceed, because we don't | 165 | // We need to wait for the engine to be done running before we proceed, because we don't |
| 166 | // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing | 166 | // want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing |
| @@ -359,10 +359,7 @@ QStringList ScriptEngines::getRunningScripts() { · 192 unmodified lines | |||
| 359 | QList<QUrl> urls = _scriptEnginesHash.keys(); | 359 | QList<QUrl> urls = _scriptEnginesHash.keys(); |
| 360 | QStringList result; | 360 | QStringList result; |
| 361 | for (auto url : urls) { | 361 | for (auto url : urls) { |
| 362 | ScriptEngine* engine = getScriptEngineInternal(url); | 362 | result.append(url.toString()); |
| 363 | if (engine) { | ||
| 364 | result.append(url.toString()); | ||
| 365 | } | ||
| 366 | } | 363 | } |
| 367 | return result; | 364 | return result; |
| 368 | } | 365 | } |
| @@ -383,7 +380,7 @@ void ScriptEngines::stopAllScripts(bool restart) { · 14 unmodified lines | |||
| 383 | // Stop and possibly restart all currently running scripts | 380 | // Stop and possibly restart all currently running scripts |
| 384 | for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); | 381 | for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin(); |
| 385 | it != _scriptEnginesHash.constEnd(); it++) { | 382 | it != _scriptEnginesHash.constEnd(); it++) { |
| 386 | if (it.value()->isFinished()) { | 383 | if (it.value()->isFinished() || it.value()->isStopping()) { |
| 387 | continue; | 384 | continue; |
| 388 | } | 385 | } |
| 389 | if (restart && it.value()->isUserLoaded()) { | 386 | if (restart && it.value()->isUserLoaded()) { |
| @@ -414,7 +411,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) { · 24 unmodified lines | |||
| 414 | reloadScript(scriptName); | 411 | reloadScript(scriptName); |
| 415 | }); | 412 | }); |
| 416 | } | 413 | } |
| 417 | scriptEngine->stop(false); | 414 | scriptEngine->stop(); |
| 418 | stoppedScript = true; | 415 | stoppedScript = true; |
| 419 | qCDebug(scriptengine) << "stopping script..." << scriptURL; | 416 | qCDebug(scriptengine) << "stopping script..." << scriptURL; |
| 420 | } | 417 | } |
| @@ -487,21 +484,19 @@ ScriptEngine* ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserL · 66 unmodified lines | |||
| 487 | return scriptEngine; | 484 | return scriptEngine; |
| 488 | } | 485 | } |
| 489 | 486 | ||
| 490 | ScriptEngine* ScriptEngines::getScriptEngineInternal(const QUrl& rawScriptURL) { | 487 | ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) { |
| 491 | ScriptEngine* result = nullptr; | 488 | ScriptEngine* result = nullptr; |
| 492 | const QUrl scriptURL = normalizeScriptURL(rawScriptURL); | 489 | { |
| 493 | auto it = _scriptEnginesHash.find(scriptURL); | 490 | QReadLocker lock(&_scriptEnginesHashLock); |
| 494 | if (it != _scriptEnginesHash.end()) { | 491 | const QUrl scriptURL = normalizeScriptURL(rawScriptURL); |
| 495 | result = it.value(); | 492 | auto it = _scriptEnginesHash.find(scriptURL); |
| 493 | if (it != _scriptEnginesHash.end()) { | ||
| 494 | result = it.value(); | ||
| 495 | } | ||
| 496 | } | 496 | } |
| 497 | return result; | 497 | return result; |
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) { | ||
| 501 | QReadLocker lock(&_scriptEnginesHashLock); | ||
| 502 | return getScriptEngineInternal(rawScriptURL); | ||
| 503 | } | ||
| 504 | |||
| 505 | // FIXME - change to new version of ScriptCache loading notification | 500 | // FIXME - change to new version of ScriptCache loading notification |
| 506 | void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { | 501 | void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { |
| 507 | UserActivityLogger::getInstance().loadedScript(rawScriptURL); | 502 | UserActivityLogger::getInstance().loadedScript(rawScriptURL); |