Physically remove only physically rendered aircrafts

Physically removing an aircraft which was not yet rendered or known is
undefined behavior.
In this particular case, adding an aircraft the first time caused
its model to be updated, which called slot
ISimulator::changeRemoteAircraftModel, trying to remove an aircraft
which was not yet added and adding it again. This ends up
in an endless loop.
This commit is contained in:
Roland Winklmeier
2016-09-07 00:34:00 +02:00
parent 0846a8773a
commit 2040ff21c5
2 changed files with 6 additions and 2 deletions

View File

@@ -109,7 +109,9 @@ namespace BlackSimPlugin
bool CSimulatorFsCommon::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
{
// remove upfront, and then enable / disable again
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
auto callsign = aircraft.getCallsign();
if (!isPhysicallyRenderedAircraft(callsign)) { return false; }
this->physicallyRemoveRemoteAircraft(callsign);
return this->changeRemoteAircraftEnabled(aircraft);
}

View File

@@ -532,7 +532,9 @@ namespace BlackSimPlugin
bool CSimulatorXPlane::changeRemoteAircraftModel(const CSimulatedAircraft &aircraft)
{
// remove upfront, and then enable / disable again
this->physicallyRemoveRemoteAircraft(aircraft.getCallsign());
auto callsign = aircraft.getCallsign();
if (!isPhysicallyRenderedAircraft(callsign)) { return false; }
this->physicallyRemoveRemoteAircraft(callsign);
return this->changeRemoteAircraftEnabled(aircraft);
}