History

first cut at shutting down scripts ahead of other cleanup

ZappoMan committed 11 years ago

Commit 0b607fa1 parent 70400f75 files · +268 −146Browse files

Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all

Unified · Split

interface/src/Application.cpp+17−1
@@ -527,12 +527,22 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 526 unmodified lines
527}527}
528 528
529void Application::aboutToQuit() {529void Application::aboutToQuit() {
530qDebug() << "Application::aboutToQuit()";
530 _aboutToQuit = true;531 _aboutToQuit = true;
531 532
532 cleanupBeforeQuit();533 cleanupBeforeQuit();
533}534}
534 535
535void Application::cleanupBeforeQuit() {536void Application::cleanupBeforeQuit() {
537 qDebug() << "Application::cleanupBeforeQuit() ------------ START -----------------";
538
539 // stop entities running scripts
540 _entities.shutdown();
541
542 // stop all running scripts
543 ScriptEngine::gracefullyStopAllScripts();
544
545
536 // first stop all timers directly or by invokeMethod546 // first stop all timers directly or by invokeMethod
537 // depending on what thread they run in547 // depending on what thread they run in
538 locationUpdateTimer->stop();548 locationUpdateTimer->stop();
@@ -572,6 +582,8 @@ void Application::cleanupBeforeQuit() { · 33 unmodified lines
572 582
573 // destroy the AudioClient so it and its thread have a chance to go down safely583 // destroy the AudioClient so it and its thread have a chance to go down safely
574 DependencyManager::destroy<AudioClient>();584 DependencyManager::destroy<AudioClient>();
585
586 qDebug() << "Application::cleanupBeforeQuit() ------------ DONE -----------------";
575}587}
576 588
577Application::~Application() { 589Application::~Application() {
@@ -3432,6 +3444,7 @@ void Application::clearScriptsBeforeRunning() { · 2854 unmodified lines
3432}3444}
3433 3445
3434void Application::saveScripts() {3446void Application::saveScripts() {
3447qDebug() << "Application::saveScripts()";
3435 // Saves all currently running user-loaded scripts3448 // Saves all currently running user-loaded scripts
3436 Settings settings;3449 Settings settings;
3437 settings.beginWriteArray(SETTINGS_KEY);3450 settings.beginWriteArray(SETTINGS_KEY);
@@ -3525,7 +3538,8 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri · 87 unmodified lines
3525#endif3538#endif
3526 3539
3527 QThread* workerThread = new QThread(this);3540 QThread* workerThread = new QThread(this);
3528 workerThread->setObjectName("Script Engine Thread");3541 QString scriptEngineName = QString("Script Thread:") + scriptEngine->getFilename();
3542 workerThread->setObjectName(scriptEngineName);
3529 3543
3530 // when the worker thread is started, call our engine's run..3544 // when the worker thread is started, call our engine's run..
3531 connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);3545 connect(workerThread, &QThread::started, scriptEngine, &ScriptEngine::run);
@@ -3599,6 +3613,7 @@ void Application::handleScriptLoadError(const QString& scriptFilename) { · 67 unmodified lines
3599}3613}
3600 3614
3601void Application::scriptFinished(const QString& scriptName) {3615void Application::scriptFinished(const QString& scriptName) {
3616 qDebug() << "Application::scriptFinished(), scriptName:" << scriptName;
3602 const QString& scriptURLString = QUrl(scriptName).toString();3617 const QString& scriptURLString = QUrl(scriptName).toString();
3603 QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString);3618 QHash<QString, ScriptEngine*>::iterator it = _scriptEnginesHash.find(scriptURLString);
3604 if (it != _scriptEnginesHash.end()) {3619 if (it != _scriptEnginesHash.end()) {
@@ -3609,6 +3624,7 @@ void Application::scriptFinished(const QString& scriptName) { · 4 unmodified lines
3609}3624}
3610 3625
3611void Application::stopAllScripts(bool restart) {3626void Application::stopAllScripts(bool restart) {
3627 qDebug() << "Application::stopAllScripts()... restart:" << restart;
3612 // stops all current running scripts3628 // stops all current running scripts
3613 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();3629 for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
3614 it != _scriptEnginesHash.constEnd(); it++) {3630 it != _scriptEnginesHash.constEnd(); it++) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t