Showing the changes to libraries/script-engine/src/ScriptEngines.cpp (1 of 1 file). Show all
Unified · Split
| @@ -31,6 +31,8 @@ static const QUrl DEFAULT_SCRIPTS_LOCATION { "file:///~//defaultScripts.js" }; · 30 unmodified lines | ||
| 31 | 31 | // Using a QVariantList so this is human-readable in the settings file |
| 32 | 32 | static Setting::Handle<QVariantList> runningScriptsHandle(SETTINGS_KEY, { QVariant(DEFAULT_SCRIPTS_LOCATION) }); |
| 33 | 33 | |
| 34 | +const int RELOAD_ALL_SCRIPTS_TIMEOUT = 1000; | |
| 35 | + | |
| 34 | 36 | |
| 35 | 37 | ScriptsModel& getScriptsModel() { |
| 36 | 38 | static ScriptsModel scriptsModel; |
| @@ -386,15 +388,10 @@ void ScriptEngines::stopAllScripts(bool restart) { · 349 unmodified lines | ||
| 386 | 388 | // queue user scripts if restarting |
| 387 | 389 | if (restart && scriptEngine->isUserLoaded()) { |
| 388 | 390 | _isReloading = true; |
| 389 | − bool lastScript = (it == _scriptEnginesHash.constEnd() - 1); | |
| 390 | 391 | ScriptEngine::Type type = scriptEngine->getType(); |
| 391 | 392 | |
| 392 | − connect(scriptEngine.data(), &ScriptEngine::finished, this, [this, type, lastScript] (QString scriptName) { | |
| 393 | + connect(scriptEngine.data(), &ScriptEngine::finished, this, [this, type] (QString scriptName) { | |
| 393 | 394 | reloadScript(scriptName, true)->setType(type); |
| 394 | − | |
| 395 | − if (lastScript) { | |
| 396 | − _isReloading = false; | |
| 397 | − } | |
| 398 | 395 | }); |
| 399 | 396 | } |
| 400 | 397 | |
| @@ -404,6 +401,9 @@ void ScriptEngines::stopAllScripts(bool restart) { · 3 unmodified lines | ||
| 404 | 401 | |
| 405 | 402 | if (restart) { |
| 406 | 403 | qCDebug(scriptengine) << "stopAllScripts -- emitting scriptsReloading"; |
| 404 | + QTimer::singleShot(RELOAD_ALL_SCRIPTS_TIMEOUT, this, [&] { | |
| 405 | + _isReloading = false; | |
| 406 | + }); | |
| 407 | 407 | emit scriptsReloading(); |
| 408 | 408 | } |
| 409 | 409 | } |