refs #801, shutdown flag in runtime

(can be used to skip functions/tasks no longer make sense during shutdown)
This commit is contained in:
Klaus Basan
2016-11-13 17:34:30 +01:00
parent 4d7e69e5b0
commit ec5bbc37ad
2 changed files with 13 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ namespace BlackCore
void CCoreFacade::init(const CCoreFacadeConfig &config)
{
if (m_init) { return; }
if (m_initalized || m_shuttingDown) { return; }
QMap<QString, int> 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);

View File

@@ -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<Application::TDBusServerAddress> m_dbusServerAddress { this };
// DBus