Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 3 files). Show all
Unified · Split
| @@ -456,7 +456,7 @@ void ScriptEngines::reloadAllScripts() { · 455 unmodified lines | |||
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, | 458 | ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor, |
| 459 | bool activateMainWindow, bool reload) { | 459 | bool activateMainWindow, bool reload, bool exitWhenFinished) { |
| 460 | if (thread() != QThread::currentThread()) { | 460 | if (thread() != QThread::currentThread()) { |
| 461 | ScriptEnginePointer result { nullptr }; | 461 | ScriptEnginePointer result { nullptr }; |
| 462 | BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), | 462 | BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result), |
| @@ -496,6 +496,11 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i · 33 unmodified lines | |||
| 496 | connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); | 496 | connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded); |
| 497 | connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); | 497 | connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError); |
| 498 | 498 | ||
| 499 | // Shutdown interface when script finishes, if requested | ||
| 500 | if (exitWhenFinished) { | ||
| 501 | connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished); | ||
| 502 | } | ||
| 503 | |||
| 499 | // get the script engine object to load the script at the designated script URL | 504 | // get the script engine object to load the script at the designated script URL |
| 500 | scriptEngine->loadURL(scriptUrl, reload); | 505 | scriptEngine->loadURL(scriptUrl, reload); |
| 501 | } | 506 | } |
| @@ -536,6 +541,10 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) { · 34 unmodified lines | |||
| 536 | emit scriptCountChanged(); | 541 | emit scriptCountChanged(); |
| 537 | } | 542 | } |
| 538 | 543 | ||
| 544 | void ScriptEngines::exitWhenFinished() { | ||
| 545 | qApp->quit(); | ||
| 546 | } | ||
| 547 | |||
| 539 | int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { | 548 | int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) { |
| 540 | int ii=0; | 549 | int ii=0; |
| 541 | for (auto initializer : _scriptInitializers) { | 550 | for (auto initializer : _scriptInitializers) { |