Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 3 files). Show all
Unified · Split
| @@ -347,7 +347,8 @@ void ScriptEngines::saveScripts() { · 346 unmodified lines | |||
| 347 | { | 347 | { |
| 348 | QReadLocker lock(&_scriptEnginesHashLock); | 348 | QReadLocker lock(&_scriptEnginesHashLock); |
| 349 | for (auto it = _scriptEnginesHash.begin(); it != _scriptEnginesHash.end(); ++it) { | 349 | for (auto it = _scriptEnginesHash.begin(); it != _scriptEnginesHash.end(); ++it) { |
| 350 | if (it.value() && it.value()->isUserLoaded()) { | 350 | // Save user-loaded scripts, only if they are set to quit when finished |
| 351 | if (it.value() && it.value()->isUserLoaded() && !it.value()->isQuitWhenFinished()) { | ||
| 351 | auto normalizedUrl = normalizeScriptURL(it.key()); | 352 | auto normalizedUrl = normalizeScriptURL(it.key()); |
| 352 | list.append(normalizedUrl.toString()); | 353 | list.append(normalizedUrl.toString()); |
| 353 | } | 354 | } |
| @@ -456,7 +457,7 @@ void ScriptEngines::reloadAllScripts() { · 102 unmodified lines | |||
| 456 | } | 457 | } |
| 457 | 458 | ||
| 458 | ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, | 459 | ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, |
| 459 | bool activateMainWindow, bool reload, bool exitWhenFinished) { | 460 | bool activateMainWindow, bool reload, bool quitWhenFinished) { |
| 460 | if (thread() != QThread::currentThread()) { | 461 | if (thread() != QThread::currentThread()) { |
| 461 | ScriptEnginePointer result { nullptr }; | 462 | ScriptEnginePointer result { nullptr }; |
| 462 | BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), | 463 | BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), |
| @@ -488,6 +489,7 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i · 25 unmodified lines | |||
| 488 | scriptEngine = ScriptEnginePointer(new ScriptEngine(_context, NO_SCRIPT, "about:" + scriptFilename.fileName())); | 489 | scriptEngine = ScriptEnginePointer(new ScriptEngine(_context, NO_SCRIPT, "about:" + scriptFilename.fileName())); |
| 489 | addScriptEngine(scriptEngine); | 490 | addScriptEngine(scriptEngine); |
| 490 | scriptEngine->setUserLoaded(isUserLoaded); | 491 | scriptEngine->setUserLoaded(isUserLoaded); |
| 492 | scriptEngine->setQuitWhenFinished(quitWhenFinished); | ||
| 491 | 493 | ||
| 492 | if (scriptFilename.isEmpty() || !scriptUrl.isValid()) { | 494 | if (scriptFilename.isEmpty() || !scriptUrl.isValid()) { |
| 493 | launchScriptEngine(scriptEngine); | 495 | launchScriptEngine(scriptEngine); |
| @@ -496,11 +498,6 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i · 2 unmodified lines | |||
| 496 | connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); | 498 | connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); |
| 497 | connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); | 499 | connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); |
| 498 | 500 | ||
| 499 | // Shutdown Interface when script finishes, if requested | ||
| 500 | if (exitWhenFinished) { | ||
| 501 | connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished); | ||
| 502 | } | ||
| 503 | |||
| 504 | // get the script engine object to load the script at the designated script URL | 501 | // get the script engine object to load the script at the designated script URL |
| 505 | scriptEngine->loadURL(scriptUrl, reload); | 502 | scriptEngine->loadURL(scriptUrl, reload); |
| 506 | } | 503 | } |
| @@ -541,10 +538,6 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { · 34 unmodified lines | |||
| 541 | emit scriptCountChanged(); | 538 | emit scriptCountChanged(); |
| 542 | } | 539 | } |
| 543 | 540 | ||
| 544 | void ScriptEngines::exitWhenFinished() { | ||
| 545 | qApp->quit(); | ||
| 546 | } | ||
| 547 | |||
| 548 | int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { | 541 | int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { |
| 549 | int ii=0; | 542 | int ii=0; |
| 550 | for (auto initializer : _scriptInitializers) { | 543 | for (auto initializer : _scriptInitializers) { |