CR for Job #20655 - Add ability to close one script from another script
Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -605,7 +605,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 604 unmodified lines | |||
| 605 | _overlays.init(); // do this before scripts load | 605 | _overlays.init(); // do this before scripts load |
| 606 | 606 | ||
| 607 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); | 607 | _runningScriptsWidget->setRunningScripts(getRunningScripts()); |
| 608 | connect(_runningScriptsWidget, &RunningScriptsWidget::stopScriptName, this, &Application::stopScript); | ||
| 609 | 608 | ||
| 610 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts())); | 609 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(saveScripts())); |
| 611 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); | 610 | connect(this, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); |
| @@ -4332,17 +4331,18 @@ void Application::stopAllScripts(bool restart) { · 3720 unmodified lines | |||
| 4332 | _myAvatar->clearScriptableSettings(); | 4331 | _myAvatar->clearScriptableSettings(); |
| 4333 | } | 4332 | } |
| 4334 | 4333 | ||
| 4335 | void Application::stopScript(const QString &scriptName, bool restart) { | 4334 | bool Application::stopScript(const QString& scriptHash, bool restart) { |
| 4336 | const QString& scriptURLString = QUrl(scriptName).toString(); | 4335 | bool stoppedScript = false; |
| 4337 | if (_scriptEnginesHash.contains(scriptURLString)) { | 4336 | if (_scriptEnginesHash.contains(scriptHash)) { |
| 4338 | ScriptEngine* scriptEngine = _scriptEnginesHash[scriptURLString]; | 4337 | ScriptEngine* scriptEngine = _scriptEnginesHash[scriptHash]; |
| 4339 | if (restart) { | 4338 | if (restart) { |
| 4340 | auto scriptCache = DependencyManager::get<ScriptCache>(); | 4339 | auto scriptCache = DependencyManager::get<ScriptCache>(); |
| 4341 | scriptCache->deleteScript(scriptName); | 4340 | scriptCache->deleteScript(QUrl(scriptHash)); |
| 4342 | connect(scriptEngine, SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); | 4341 | connect(scriptEngine, SIGNAL(finished(const QString&)), SLOT(reloadScript(const QString&))); |
| 4343 | } | 4342 | } |
| 4344 | scriptEngine->stop(); | 4343 | scriptEngine->stop(); |
| 4345 | qCDebug(interfaceapp) << "stopping script..." << scriptName; | 4344 | stoppedScript = true; |
| 4345 | qCDebug(interfaceapp) << "stopping script..." << scriptHash; | ||
| 4346 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities | 4346 | // HACK: ATM scripts cannot set/get their animation priorities, so we clear priorities |
| 4347 | // whenever a script stops in case it happened to have been setting joint rotations. | 4347 | // whenever a script stops in case it happened to have been setting joint rotations. |
| 4348 | // TODO: expose animation priorities and provide a layered animation control system. | 4348 | // TODO: expose animation priorities and provide a layered animation control system. |
| @@ -4351,6 +4351,7 @@ void Application::stopScript(const QString &scriptName, bool restart) { · 2 unmodified lines | |||
| 4351 | if (_scriptEnginesHash.empty()) { | 4351 | if (_scriptEnginesHash.empty()) { |
| 4352 | _myAvatar->clearScriptableSettings(); | 4352 | _myAvatar->clearScriptableSettings(); |
| 4353 | } | 4353 | } |
| 4354 | return stoppedScript; | ||
| 4354 | } | 4355 | } |
| 4355 | 4356 | ||
| 4356 | void Application::reloadAllScripts() { | 4357 | void Application::reloadAllScripts() { |