mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Guard QTimer::singleShot
This commit is contained in:
committed by
Roland Winklmeier
parent
3ecb7b1f94
commit
3f4cb7529c
@@ -38,6 +38,7 @@
|
||||
#include <QThread>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
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<CContextSimulator> myself(this);
|
||||
QTimer::singleShot(1250, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->initByLastUsedModelSet();
|
||||
});
|
||||
}
|
||||
|
||||
CContextSimulator *CContextSimulator::registerWithDBus(CDBusServer *server)
|
||||
|
||||
@@ -32,7 +32,13 @@ namespace BlackGui
|
||||
this->setPlaceholderText(".dot commands");
|
||||
}
|
||||
|
||||
QTimer::singleShot(5000, &m_dsCommandTooltip, &CDigestSignal::inputSignal);
|
||||
const QPointer<CCommandInput> myself(this);
|
||||
QTimer::singleShot(5000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
m_dsCommandTooltip.inputSignal();
|
||||
});
|
||||
|
||||
if (sGui && sGui->supportsContexts())
|
||||
{
|
||||
if (sGui->getIContextSimulator())
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QToolButton>
|
||||
#include <Qt>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
@@ -453,7 +454,13 @@ namespace BlackGui
|
||||
{
|
||||
std::function<void()> f = m_pendingMessageCalls.front();
|
||||
m_pendingMessageCalls.removeFirst();
|
||||
QTimer::singleShot(500, this, f);
|
||||
const QPointer<COverlayMessages> myself(this);
|
||||
QTimer::singleShot(500, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
f();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "digestsignal.h"
|
||||
#include "threadutils.h"
|
||||
#include <QPointer>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
@@ -17,7 +18,12 @@ namespace BlackMisc
|
||||
if (!CThreadUtils::isCurrentThreadObjectThread(this))
|
||||
{
|
||||
// call in correct thread
|
||||
QTimer::singleShot(0, this, &CDigestSignal::inputSignal);
|
||||
const QPointer<CDigestSignal> 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
|
||||
|
||||
Reference in New Issue
Block a user