Prevent killing timer with wrong id

This commit is contained in:
Klaus Basan
2016-11-15 23:19:19 +01:00
parent 2e5176ebcc
commit 871a1dd321
2 changed files with 6 additions and 13 deletions

View File

@@ -69,9 +69,9 @@ namespace BlackGui
void CLoadIndicator::setAnimationDelay(int delay) void CLoadIndicator::setAnimationDelay(int delay)
{ {
if (this->m_timerId != -1) { killTimer(this->m_timerId); }
this->m_delayMs = delay; this->m_delayMs = delay;
if (this->m_timerId != -1) { this->m_timerId = startTimer(this->m_delayMs); } if (this->m_timerId != -1) { killTimer(this->m_timerId); }
this->m_timerId = startTimer(this->m_delayMs);
} }
void CLoadIndicator::setColor(const QColor &color) void CLoadIndicator::setColor(const QColor &color)

View File

@@ -104,11 +104,8 @@ namespace BlackSimPlugin
bool CSimulatorFsx::disconnectFrom() bool CSimulatorFsx::disconnectFrom()
{ {
if (!m_simConnected) { return true; } if (!m_simConnected) { return true; }
if (m_simconnectTimerId >= 0) if (m_simconnectTimerId >= 0) { killTimer(m_simconnectTimerId); }
{ m_simconnectTimerId = -1;
killTimer(m_simconnectTimerId);
m_simconnectTimerId = -1;
}
if (m_hSimConnect) if (m_hSimConnect)
{ {
SimConnect_Close(m_hSimConnect); SimConnect_Close(m_hSimConnect);
@@ -1042,15 +1039,11 @@ namespace BlackSimPlugin
void CSimulatorFsx::reset() void CSimulatorFsx::reset()
{ {
if (m_simconnectTimerId >= 0) if (m_simconnectTimerId >= 0) { killTimer(m_simconnectTimerId); }
{ m_simconnectTimerId = -1;
killTimer(m_simconnectTimerId);
m_simconnectTimerId = -1;
}
m_simConnected = false; m_simConnected = false;
m_simSimulating = false; m_simSimulating = false;
m_syncDeferredCounter = 0; m_syncDeferredCounter = 0;
m_simconnectTimerId = -1;
m_skipCockpitUpdateCycles = 0; m_skipCockpitUpdateCycles = 0;
m_interpolationRequest = 0; m_interpolationRequest = 0;
m_interpolationsSkipped = 0; m_interpolationsSkipped = 0;