diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index ea548c072..c7b1033aa 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace BlackConfig; using namespace BlackMisc; @@ -68,12 +69,18 @@ namespace BlackCore this->restoreSimulatorPlugins(); connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived); - // seems to be redundant, as changed sim will cause changed cache - // connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDigestSignal::modelSetChanged); connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::modelSetChanged); + // seems to be redundant, as changed simulator will cause changed cache + // connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDigestSignal::modelSetChanged); + // deferred init of last model set, if no other data are set in meantime - QTimer::singleShot(1250, this, &CContextSimulator::initByLastUsedModelSet); + const QPointer myself(this); + QTimer::singleShot(1250, this, [ = ] + { + if (!myself) { return; } + this->initByLastUsedModelSet(); + }); } CContextSimulator *CContextSimulator::registerWithDBus(CDBusServer *server) diff --git a/src/blackgui/components/commandinput.cpp b/src/blackgui/components/commandinput.cpp index 2f385d130..5c3825ed3 100644 --- a/src/blackgui/components/commandinput.cpp +++ b/src/blackgui/components/commandinput.cpp @@ -32,7 +32,13 @@ namespace BlackGui this->setPlaceholderText(".dot commands"); } - QTimer::singleShot(5000, &m_dsCommandTooltip, &CDigestSignal::inputSignal); + const QPointer myself(this); + QTimer::singleShot(5000, this, [ = ] + { + if (!myself) { return; } + m_dsCommandTooltip.inputSignal(); + }); + if (sGui && sGui->supportsContexts()) { if (sGui->getIContextSimulator()) diff --git a/src/blackgui/overlaymessages.cpp b/src/blackgui/overlaymessages.cpp index ddc8cb25d..1f9e45ba8 100644 --- a/src/blackgui/overlaymessages.cpp +++ b/src/blackgui/overlaymessages.cpp @@ -35,6 +35,7 @@ #include #include #include +#include using namespace BlackMisc; using namespace BlackMisc::Network; @@ -453,7 +454,13 @@ namespace BlackGui { std::function f = m_pendingMessageCalls.front(); m_pendingMessageCalls.removeFirst(); - QTimer::singleShot(500, this, f); + const QPointer myself(this); + QTimer::singleShot(500, this, [ = ] + { + if (!myself) { return; } + if (!sGui || sGui->isShuttingDown()) { return; } + f(); + }); } } diff --git a/src/blackmisc/digestsignal.cpp b/src/blackmisc/digestsignal.cpp index 9fd55ffe8..c8dc6123f 100644 --- a/src/blackmisc/digestsignal.cpp +++ b/src/blackmisc/digestsignal.cpp @@ -9,6 +9,7 @@ #include "digestsignal.h" #include "threadutils.h" +#include namespace BlackMisc { @@ -17,7 +18,12 @@ namespace BlackMisc if (!CThreadUtils::isCurrentThreadObjectThread(this)) { // call in correct thread - QTimer::singleShot(0, this, &CDigestSignal::inputSignal); + const QPointer myself(this); + QTimer::singleShot(0, this, [ = ] + { + if (!myself) { return; } + this->inputSignal(); + }); return; } @@ -33,7 +39,7 @@ namespace BlackMisc { m_timer.stop(); m_inputsCount = 0; - emit digestSignal(); + emit this->digestSignal(); } void CDigestSignal::init(int maxDelayMs) @@ -42,5 +48,4 @@ namespace BlackMisc m_timer.setSingleShot(true); m_timer.setInterval(maxDelayMs); } - } // namespace