Make sure contexts are "gracefulShutdown"

The shutdown was NOT called as it was canceled because of being in shutdown mode
This commit is contained in:
Klaus Basan
2020-03-30 20:29:43 +02:00
committed by Mat Sutcliffe
parent 53bd5e6be7
commit cb78453e7c
2 changed files with 9 additions and 6 deletions

View File

@@ -250,7 +250,7 @@ namespace BlackCore
bool CApplication::isShuttingDown() const
{
return m_shutdown;
return m_shutdown || m_shutdownInProgress;
}
bool CApplication::isIncognito() const
@@ -1069,7 +1069,6 @@ namespace BlackCore
// mark as shutdown
if (m_networkWatchDog) { m_networkWatchDog->gracefulShutdown(); }
m_shutdown = true;
// save settings (but only when application was really alive)
if (m_parsed && m_saveSettingsOnShutdown)
@@ -1083,7 +1082,7 @@ namespace BlackCore
// from here on we really rip apart the application object
// and it should no longer be used
if (this->supportsContexts())
if (this->supportsContexts(true))
{
CLogMessage(this).info(u"Graceful shutdown of CApplication, shutdown of contexts");
@@ -1117,8 +1116,12 @@ namespace BlackCore
// clean up all in "deferred delete state"
qApp->sendPostedEvents(nullptr, QEvent::DeferredDelete);
sApp->processEventsFor(500);
// completed
m_shutdown = true;
sApp = nullptr;
disconnect(this);
}
@@ -1548,9 +1551,9 @@ namespace BlackCore
// Contexts
// ---------------------------------------------------------------------------------
bool CApplication::supportsContexts() const
bool CApplication::supportsContexts(bool ignoreShutdownTest) const
{
if (m_shutdown) { return false; }
if (!ignoreShutdownTest && m_shutdown) { return false; }
if (m_coreFacade.isNull()) { return false; }
if (!m_coreFacade->getIContextApplication()) { return false; }
return (!m_coreFacade->getIContextApplication()->isEmptyObject());

View File

@@ -346,7 +346,7 @@ namespace BlackCore
//! Supports contexts
//! \remark checks the real availability of the contexts, so it can happen that we want to use contexts, and they are not yet initialized (false here)
//! \sa m_useContexts we use or we will use contexts
bool supportsContexts() const;
bool supportsContexts(bool ignoreShutdownTest = false) const;
//! The core facade config
const CCoreFacadeConfig &getCoreFacadeConfig() const { return m_coreFacadeConfig; }