From 43cc99710a1fa3ee8584d4ea45949b39f858eaba Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 10 May 2018 03:58:08 +0200 Subject: [PATCH] Shutdown guard --- src/blackgui/components/aircraftpartshistory.cpp | 1 + src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/blackgui/components/aircraftpartshistory.cpp b/src/blackgui/components/aircraftpartshistory.cpp index df7e48a12..6d3c964fa 100644 --- a/src/blackgui/components/aircraftpartshistory.cpp +++ b/src/blackgui/components/aircraftpartshistory.cpp @@ -56,6 +56,7 @@ namespace BlackGui void CAircraftPartsHistory::initGui() { + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextNetwork()) { return; } const bool needCallsigns = this->partsHistoryEnabled(); if (needCallsigns && !m_timerUpdateHistory.isActive()) { diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index 666aabc40..c828fb5e9 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -309,8 +309,10 @@ namespace BlackSimPlugin void CSimulatorFsxCommon::onSimRunning() { + const QPointer myself(this); QTimer::singleShot(DeferSimulatingFlagMs, this, [ = ] { + if (myself.isNull()) { return; } m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch(); this->onSimRunningDefered(m_simulatingChangedTs); }); @@ -567,9 +569,11 @@ namespace BlackSimPlugin // we know the object has been created. But it can happen it is directly removed afterwards const CSimulatedAircraft verifyAircraft(simObject.getAircraft()); + const QPointer myself(this); QTimer::singleShot(1000, this, [ = ] { // also triggers new add if required + if (myself.isNull()) { return; } this->verifyAddedRemoteAircraft(verifyAircraft); }); return true; @@ -1099,10 +1103,10 @@ namespace BlackSimPlugin } // cleanup function, actually this should not be needed - const QPointer guard(this); + const QPointer myself(this); QTimer::singleShot(100, this, [ = ] { - if (guard.isNull()) { return; } + if (myself.isNull()) { return; } CSimulatorFsxCommon::physicallyRemoveAircraftNotInProvider(); });