diff --git a/src/blackcore/corefacade.cpp b/src/blackcore/corefacade.cpp index 03664caf4..b018ad93e 100644 --- a/src/blackcore/corefacade.cpp +++ b/src/blackcore/corefacade.cpp @@ -52,7 +52,7 @@ namespace BlackCore void CCoreFacade::init(const CCoreFacadeConfig &config) { - if (m_init) { return; } + if (m_initalized || m_shuttingDown) { return; } QMap times; QTime time; @@ -116,7 +116,7 @@ namespace BlackCore CLogMessage(this).info("Init times: %1") << qmapToString(times); // flag - m_init = true; + m_initalized = true; } bool CCoreFacade::hasRemoteApplicationContext() const @@ -227,8 +227,9 @@ namespace BlackCore void CCoreFacade::gracefulShutdown() { - if (!this->m_init) return; - this->m_init = false; + if (!this->m_initalized) { return; } + if (m_shuttingDown) { return; } + this->m_shuttingDown = true; // disable all signals towards runtime disconnect(this); diff --git a/src/blackcore/corefacade.h b/src/blackcore/corefacade.h index 8ad0f5811..a8edf25a2 100644 --- a/src/blackcore/corefacade.h +++ b/src/blackcore/corefacade.h @@ -45,9 +45,9 @@ namespace BlackCore } /*! - * The runtime class providing facades (the contexts) for all DBus relevant operations. - * - Initializes all contexts in correct order - * - Allows a ordered and correct shutdown + * The class providing facades (the contexts) for all DBus relevant operations. + * - It initializes all contexts in correct order + * - Allows an ordered and correct shutdown * - Connects all signal/slots between contexts * (such cross context dependencies are not desired but sometimes required) * - Loads the application settings @@ -72,6 +72,9 @@ namespace BlackCore //! Clean up (will be connected to signal QCoreApplication::aboutToQuit) void gracefulShutdown(); + //! Facade and context shutting down + bool isShuttingDown() const { return m_shuttingDown; } + // ------- Context as interface, normal way to access a context //! Context for network @@ -160,7 +163,8 @@ namespace BlackCore bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator); private: - bool m_init = false; //!< flag + bool m_initalized = false; //!< flag if already initialized + bool m_shuttingDown = false; //!< flag if shutting down BlackMisc::CSetting m_dbusServerAddress { this }; // DBus