Ref T180, stop requesting data when aircraft is removed

This commit is contained in:
Klaus Basan
2017-11-09 19:58:53 +01:00
parent cd838b2cb6
commit 868ae7ec74
2 changed files with 13 additions and 1 deletions

View File

@@ -69,6 +69,9 @@ namespace BlackSimPlugin
//! Set current lights when received from simulator
void setCurrentLightsInSimulator(const BlackMisc::Aviation::CAircraftLights &lights) { m_currentLightsInSim = lights; }
//! Pretend to have received lights from simulator
void fakeCurrentLightsInSimulator() { m_currentLightsInSim.setNull(false); }
//! Parts as sent to simulator
const DataDefinitionRemoteAircraftPartsWithoutLights &getPartsAsSent() const { return m_partsAsSent; }

View File

@@ -895,10 +895,17 @@ namespace BlackSimPlugin
CSimConnectObject &simObject = m_simConnectObjects[callsign];
if (simObject.isPendingRemoved()) { return true; }
if (simObject.isPendingAdded())
// avoid further data from simulator
this->stopRequestingDataForSimObject(simObject);
const bool pendingAdded = simObject.isPendingAdded();
const bool stillWaitingForLights = !simObject.hasCurrentLightsInSimulator();
if (pendingAdded || stillWaitingForLights)
{
// problem: we try to delete an aircraft just requested to be added
// best solution so far, call remove again with a delay
simObject.fakeCurrentLightsInSimulator(); // next time looks like we have lights
QTimer::singleShot(2000, this, [ = ]
{
this->physicallyRemoveRemoteAircraft(callsign);
@@ -1443,6 +1450,8 @@ namespace BlackSimPlugin
bool CSimulatorFsxCommon::requestLightsForSimObject(const CSimConnectObject &simObject)
{
if (!simObject.hasValidRequestAndObjectId()) { return false; }
if (simObject.isPendingRemoved()) { return false; }
if (!m_hSimConnect) { return false; }
// always request, not only when something has changed
const HRESULT result = SimConnect_RequestDataOnSimObject(