diff --git a/src/blackcore/application.cpp b/src/blackcore/application.cpp index bd11957b9..a4c78b4b4 100644 --- a/src/blackcore/application.cpp +++ b/src/blackcore/application.cpp @@ -974,13 +974,8 @@ namespace BlackCore // info that we will shutdown emit this->aboutToShutdown(); - // before marked as shutdown, otherwise URL - if (m_networkWatchDog) - { - m_networkWatchDog->gracefulShutdown(); - } - // mark as shutdown + if (m_networkWatchDog) { m_networkWatchDog->gracefulShutdown(); } m_shutdown = true; // save settings (but only when application was really alive) @@ -1035,11 +1030,7 @@ namespace BlackCore } emit this->setupHandlingCompleted(available); - - if (m_signalStartup) - { - emit this->startUpCompleted(m_started); - } + if (m_signalStartup) { emit this->startUpCompleted(m_started); } } void CApplication::onStartUpCompleted() diff --git a/src/blackcore/application.h b/src/blackcore/application.h index 1e277f6fc..96ff55ee8 100644 --- a/src/blackcore/application.h +++ b/src/blackcore/application.h @@ -334,16 +334,16 @@ namespace BlackCore //! \name Direct access to contexts if a CCoreFacade has been initialized //! @{ - const Context::IContextNetwork *getIContextNetwork() const; - const Context::IContextAudio *getIContextAudio() const; + const Context::IContextNetwork *getIContextNetwork() const; + const Context::IContextAudio *getIContextAudio() const; const Context::IContextApplication *getIContextApplication() const; const Context::IContextOwnAircraft *getIContextOwnAircraft() const; - const Context::IContextSimulator *getIContextSimulator() const; - Context::IContextNetwork *getIContextNetwork(); - Context::IContextAudio *getIContextAudio(); - Context::IContextApplication *getIContextApplication(); - Context::IContextOwnAircraft *getIContextOwnAircraft(); - Context::IContextSimulator *getIContextSimulator(); + const Context::IContextSimulator *getIContextSimulator() const; + Context::IContextNetwork *getIContextNetwork(); + Context::IContextAudio *getIContextAudio(); + Context::IContextApplication *getIContextApplication(); + Context::IContextOwnAircraft *getIContextOwnAircraft(); + Context::IContextSimulator *getIContextSimulator(); //! @} // ----------------------- setup data --------------------------------- diff --git a/src/blackgui/guiapplication.cpp b/src/blackgui/guiapplication.cpp index 512c02ff7..856606970 100644 --- a/src/blackgui/guiapplication.cpp +++ b/src/blackgui/guiapplication.cpp @@ -471,9 +471,9 @@ namespace BlackGui QMenu *sm = menu.addMenu(CIcons::appSettings16(), "Settings"); sm->setIcon(CIcons::appSettings16()); QAction *a = sm->addAction(CIcons::disk16(), "Settings directory"); - QPointer myself(this); bool c = connect(a, &QAction::triggered, this, [ = ]() { + if (!sGui || sGui->isShuttingDown()) { return; } const QString path(QDir::toNativeSeparators(CSettingsCache::persistentStore())); if (QDir(path).exists()) { @@ -485,18 +485,18 @@ namespace BlackGui a = sm->addAction("Reset settings"); c = connect(a, &QAction::triggered, this, [ = ] { - if (myself.isNull()) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } CSettingsCache::instance()->clearAllValues(); - myself->displayTextInConsole("Cleared all settings!"); + this->displayTextInConsole("Cleared all settings!"); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = sm->addAction("List settings files"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (myself.isNull()) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files(CSettingsCache::instance()->enumerateStore()); - myself->displayTextInConsole(files.join("\n")); + this->displayTextInConsole(files.join("\n")); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); @@ -516,7 +516,7 @@ namespace BlackGui a = sm->addAction("Reset cache"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (myself.isNull()) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files = CApplication::clearCaches(); this->displayTextInConsole("Cleared caches! " + QString::number(files.size()) + " files"); }); @@ -525,9 +525,9 @@ namespace BlackGui a = sm->addAction("List cache files"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (myself.isNull()) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } const QStringList files(CDataCache::instance()->enumerateStore()); - myself->displayTextInConsole(files.join("\n")); + this->displayTextInConsole(files.join("\n")); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); @@ -540,6 +540,7 @@ namespace BlackGui QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } }); + Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); a = menu.addAction(CIcons::swift24(), "Check for updates"); c = connect(a, &QAction::triggered, this, &CGuiApplication::checkNewVersionMenu); @@ -564,21 +565,20 @@ namespace BlackGui void CGuiApplication::addMenuForStyleSheets(QMenu &menu) { - QPointer myself(this); QMenu *sm = menu.addMenu("Style sheet"); QAction *aReload = sm->addAction(CIcons::refresh16(), "Reload"); bool c = connect(aReload, &QAction::triggered, this, [ = ]() { - if (myself.isNull()) { return; } - myself->reloadStyleSheets(); + if (!sGui || sGui->isShuttingDown()) { return; } + this->reloadStyleSheets(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); QAction *aOpen = sm->addAction(CIcons::text16(), "Open qss file"); c = connect(aOpen, &QAction::triggered, this, [ = ]() { - if (myself.isNull()) { return; } - myself->openStandardWidgetStyleSheet(); + if (!sGui || sGui->isShuttingDown()) { return; } + this->openStandardWidgetStyleSheet(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); Q_UNUSED(c); @@ -601,13 +601,12 @@ namespace BlackGui menu.addSeparator(); a = menu.addAction("E&xit"); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Q)); - QPointer myself(this); c = connect(a, &QAction::triggered, this, [ = ]() { // a close event might already trigger a shutdown - if (!myself) { return; } - myself->mainApplicationWidget()->close(); - myself->gracefulShutdown(); + if (!sGui || sGui->isShuttingDown()) { return; } + this->mainApplicationWidget()->close(); + this->gracefulShutdown(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); Q_UNUSED(c); @@ -615,12 +614,11 @@ namespace BlackGui void CGuiApplication::addMenuInternals(QMenu &menu) { - QPointer myself(this); QMenu *sm = menu.addMenu("Templates"); QAction *a = sm->addAction("JSON bootstrap"); bool c = connect(a, &QAction::triggered, this, [ = ]() { - if (!myself) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } const CGlobalSetup s = this->getGlobalSetup(); this->displayTextInConsole(s.toJsonString()); }); @@ -629,9 +627,9 @@ namespace BlackGui a = sm->addAction("JSON update info (for info only)"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (!myself) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } const CUpdateInfo info = this->getUpdateInfo(); - myself->displayTextInConsole(info.toJsonString()); + this->displayTextInConsole(info.toJsonString()); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); @@ -640,8 +638,8 @@ namespace BlackGui a = menu.addAction("Services log.(console)"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (!myself) { return; } - myself->displayTextInConsole(this->getWebDataServices()->getReadersLog()); + if (!sGui || sGui->isShuttingDown()) { return; } + this->displayTextInConsole(this->getWebDataServices()->getReadersLog()); CLogMessage(this).info("Displayed services log."); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); @@ -650,8 +648,8 @@ namespace BlackGui a = menu.addAction("Metadata (slow)"); c = connect(a, &QAction::triggered, this, [ = ]() { - if (!myself) { return; } - myself->displayTextInConsole(getAllUserMetatypesTypes()); + if (!sGui || sGui->isShuttingDown()) { return; } + this->displayTextInConsole(getAllUserMetatypesTypes()); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); Q_UNUSED(c); @@ -707,12 +705,11 @@ namespace BlackGui QPointer w = mainApplicationWidget(); if (!w) { return; } QAction *a = menu.addAction(w->style()->standardIcon(QStyle::SP_TitleBarContextHelpButton), "Online help"); - QPointer myself(this); bool c = connect(a, &QAction::triggered, this, [ = ]() { - if (!myself) { return; } - myself->showHelp(); + if (!sGui || sGui->isShuttingDown()) { return; } + this->showHelp(); }); Q_ASSERT_X(c, Q_FUNC_INFO, "Connect failed"); diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp index 3f7975e2b..a11571a73 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.cpp @@ -29,14 +29,14 @@ namespace BlackSimPlugin ui->comp_SettingsXSwiftBus->setDefaultP2PAddress(m_xswiftbusServerSetting.getDefault()); ui->comp_SettingsXSwiftBus->set(m_xswiftbusServerSetting.getThreadLocal()); - connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::settingsAccepted); + connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::onSettingsAccepted); connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close); } CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow() { } - void CSimulatorXPlaneConfigWindow::settingsAccepted() + void CSimulatorXPlaneConfigWindow::onSettingsAccepted() { const QString currentAddress = m_xswiftbusServerSetting.getThreadLocal(); if (currentAddress != ui->comp_SettingsXSwiftBus->getDBusAddress()) @@ -45,6 +45,5 @@ namespace BlackSimPlugin } close(); } - } // ns } // ns diff --git a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h index 6ff97a493..4d7408897 100644 --- a/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h +++ b/src/plugins/simulator/xplaneconfig/simulatorxplaneconfigwindow.h @@ -18,8 +18,6 @@ #include #include -class QWidget; - namespace Ui { class CSimulatorXPlaneConfigWindow; } namespace BlackSimPlugin { @@ -40,7 +38,8 @@ namespace BlackSimPlugin virtual ~CSimulatorXPlaneConfigWindow(); private: - void settingsAccepted(); + //! Settings have been accepted + void onSettingsAccepted(); QScopedPointer ui; BlackMisc::CSetting m_xswiftbusServerSetting { this };