Ref T232, some (dispatch) timer code was duplicated

* fixed a bug, where a non existing timer was killed
* unified code in base class
This commit is contained in:
Klaus Basan
2018-01-20 07:22:19 +01:00
parent af75c88784
commit dac1ee85f9
6 changed files with 22 additions and 13 deletions

View File

@@ -90,7 +90,7 @@ namespace BlackSimPlugin
// set structures and move on
this->initEvents();
this->initDataDefinitionsWhenConnected();
m_simConnectTimerId = startTimer(DispatchIntervalMs);
m_timerId = startTimer(DispatchIntervalMs);
// do not start m_addPendingAircraftTimer here, it will be started when object was added
return true;
@@ -99,8 +99,7 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::disconnectFrom()
{
if (!m_simConnected) { return true; }
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
m_simConnectTimerId = -1;
this->safeKillTimer();
m_simSimulating = false; // treat as stopped, just setting the flag here avoids overhead of on onSimStopped
if (m_hSimConnect)
{
@@ -338,7 +337,7 @@ namespace BlackSimPlugin
{
// reset complete state, we are going down
m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch();
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
this->safeKillTimer();
// if called from dispatch function, avoid that SimConnectProc disconnects itself while in SimConnectProc
QTimer::singleShot(0, this, &CSimulatorFsxCommon::disconnectFrom);
@@ -1503,8 +1502,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::reset()
{
if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); }
m_simConnectTimerId = -1;
this->safeKillTimer();
m_simulatingChangedTs = -1;
m_simConnected = false;
m_simSimulating = false;

View File

@@ -154,7 +154,7 @@ namespace BlackSimPlugin
//! @}
//! Timer event (our SimConnect event loop), runs dispatch
//! \sa m_simconnectTimerId
//! \sa m_timerId
//! \sa CSimulatorFsxCommon::dispatch
virtual void timerEvent(QTimerEvent *event) override;
@@ -354,7 +354,6 @@ namespace BlackSimPlugin
bool m_traceSendId = false; //!< trace the send ids, meant for dedugging
qint64 m_simulatingChangedTs = -1; //!< timestamp, when simulating changed (used to avoid jitter)
int m_syncDeferredCounter = 0; //!< Set when synchronized, used to wait some time
int m_simConnectTimerId = -1; //!< Timer identifier
int m_skipCockpitUpdateCycles = 0; //!< skip some update cycles to allow changes in simulator cockpit to be set
int m_interpolationRequest = 0; //!< current interpolation request
int m_dispatchErrors = 0; //!< number of dispatched failed, \sa dispatch