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

@@ -85,7 +85,10 @@ namespace BlackCore
CLogMessage(this).info("Initialized simulator driver: '%1'") << m_simulatorPluginInfo.toQString();
}
CSimulatorCommon::~CSimulatorCommon() { }
CSimulatorCommon::~CSimulatorCommon()
{
this->safeKillTimer();
}
const CLogCategoryList &CSimulatorCommon::getLogCategories()
{
@@ -500,6 +503,13 @@ namespace BlackCore
this->blinkHighlightedAircraft();
}
void CSimulatorCommon::safeKillTimer()
{
if (m_timerId < 0) { return; }
this->killTimer(m_timerId);
m_timerId = -1;
}
void CSimulatorCommon::onRecalculatedRenderedAircraft(const CAirspaceAircraftSnapshot &snapshot)
{
if (!snapshot.isValidSnapshot()) { return;}

View File

@@ -206,8 +206,12 @@ namespace BlackCore
//! Slow timer used to highlight aircraft, can be used for other things too
virtual void oneSecondTimerTimeout();
//! Kill timer if id is valid
void safeKillTimer();
bool m_pausedSimFreezesInterpolation = false; //!< paused simulator will also pause interpolation (so AI aircraft will hold)
bool m_autoCalcAirportDistance = true; //!< automatically calculate airport distance and bearing
int m_timerId = -1; //!< dispatch timer id
int m_statsUpdateAircraftCountMs = 0; //!< statistics update count
qint64 m_statsUpdateAircraftTimeTotalMs = 0; //!< statistics update time
qint64 m_statsUpdateAircraftTimeAvgMs = 0; //!< statistics update time