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 | 348 | QReadLocker lock(&_scriptEnginesHashLock); |
| 349 | 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 | 352 | auto normalizedUrl = normalizeScriptURL(it.key()); |
| 352 | 353 | list.append(normalizedUrl.toString()); |
| 353 | 354 | } |
| @@ -456,7 +457,7 @@ void ScriptEngines::reloadAllScripts() { · 102 unmodified lines | ||
| 456 | 457 | } |
| 457 | 458 | |
| 458 | 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 | 461 | if (thread() != QThread::currentThread()) { |
| 461 | 462 | ScriptEnginePointer result { nullptr }; |
| 462 | 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 | 489 | scriptEngine = ScriptEnginePointer(new ScriptEngine(_context, NO_SCRIPT, "about:" + scriptFilename.fileName())); |
| 489 | 490 | addScriptEngine(scriptEngine); |
| 490 | 491 | scriptEngine->setUserLoaded(isUserLoaded); |
| 492 | + scriptEngine->setQuitWhenFinished(quitWhenFinished); | |
| 491 | 493 | |
| 492 | 494 | if (scriptFilename.isEmpty() || !scriptUrl.isValid()) { |
| 493 | 495 | launchScriptEngine(scriptEngine); |
| @@ -496,11 +498,6 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i · 2 unmodified lines | ||
| 496 | 498 | connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); |
| 497 | 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 | 501 | // get the script engine object to load the script at the designated script URL |
| 505 | 502 | scriptEngine->loadURL(scriptUrl, reload); |
| 506 | 503 | } |
| @@ -541,10 +538,6 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { · 34 unmodified lines | ||
| 541 | 538 | emit scriptCountChanged(); |
| 542 | 539 | } |
| 543 | 540 | |
| 544 | −void ScriptEngines::exitWhenFinished() { | |
| 545 | − qApp->quit(); | |
| 546 | −} | |
| 547 | − | |
| 548 | 541 | int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { |
| 549 | 542 | int ii=0; |
| 550 | 543 | for (auto initializer : _scriptInitializers) { |