Checks to avoid crash during shutdown

This commit is contained in:
Klaus Basan
2019-03-28 18:57:12 +01:00
committed by Mat Sutcliffe
parent f54d85dfbc
commit 8223ddb710
2 changed files with 9 additions and 6 deletions

View File

@@ -671,6 +671,7 @@ namespace BlackGui
void CLoginComponent::lookupOwnAircraftModel()
{
if (!this->hasValidContexts()) { return; }
if (!sGui->getIContextSimulator()->isSimulatorAvailable()) { return; }
const CAircraftModel model(sGui->getIContextOwnAircraft()->getOwnAircraft().getModel());
this->onSimulatorModelChanged(model);

View File

@@ -541,7 +541,7 @@ namespace BlackGui
}
}
emit changedWholeInfoAreaFloating(floating);
emit this->changedWholeInfoAreaFloating(floating);
}
void CInfoArea::tabifyAllWidgets()
@@ -601,9 +601,9 @@ namespace BlackGui
// South does not have any effect
m_tabBar->setShape(QTabBar::TriangularSouth);
// signals
connect(m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::onTabBarDoubleClicked);
connect(m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::onTabBarIndexChanged);
// signals, use Qt::QueuedConnection to avoid issues during shutdown
connect(m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::onTabBarDoubleClicked, Qt::QueuedConnection);
connect(m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::onTabBarIndexChanged, Qt::QueuedConnection);
}
else
{
@@ -657,15 +657,16 @@ namespace BlackGui
void CInfoArea::emitInfoAreaStatus()
{
if (!sGui || sGui->isShuttingDown()) { return; } // avoid access to deleted components
const int sia = this->getSelectedDockInfoAreaIndex();
const QList<int> floating = this->getAreaIndexesDockedOrFloating(true);
const QList<int> docked = this->getAreaIndexesDockedOrFloating(false);
emit changedInfoAreaStatus(sia, docked, floating);
emit this->changedInfoAreaStatus(sia, docked, floating);
}
void CInfoArea::onTabBarIndexChanged(int tabBarIndex)
{
emit changedInfoAreaTabBarIndex(tabBarIndex);
emit this->changedInfoAreaTabBarIndex(tabBarIndex);
emitInfoAreaStatus();
}
@@ -804,6 +805,7 @@ namespace BlackGui
{
if (m_tabBar)
{
if (!sGui || sGui->isShuttingDown()) { return; }
const QString qss = sGui->getStyleSheetUtility().style(CStyleSheetUtility::fileNameDockWidgetTab());
m_tabBar->setStyleSheet(qss);
}