Ref T259, only remove aircraft after data have been used, otherwise a dangling reference causes a crash

This commit is contained in:
Klaus Basan
2018-02-25 15:31:41 +01:00
parent 41109dd761
commit 13ede9fac1
2 changed files with 6 additions and 9 deletions

View File

@@ -651,24 +651,21 @@ namespace BlackSimPlugin
// really remove from simulator
if (!m_xplaneAircraft.contains(callsign)) { return false; } // already fully removed or not yet added
CXPlaneMPAircraft &xplaneAircraft = m_xplaneAircraft[callsign];
// avoid further data from simulator
// this->stopRequestingDataForSimObject(simObject);
m_traffic->removePlane(callsign.asString());
m_xplaneAircraft.remove(callsign);
// mark in provider
const bool updated = this->updateAircraftRendered(callsign, false);
if (updated)
{
Q_ASSERT_X(m_xplaneAircraft.contains(callsign), Q_FUNC_INFO, "Aircraft removed");
const CXPlaneMPAircraft &xplaneAircraft = m_xplaneAircraft[callsign];
CSimulatedAircraft aircraft(xplaneAircraft.getAircraft());
aircraft.setRendered(false);
emit this->aircraftRenderingChanged(aircraft);
}
m_traffic->removePlane(callsign.asString());
m_xplaneAircraft.remove(callsign);
// bye
return true;
}

View File

@@ -37,9 +37,9 @@
#include <QObject>
#include <QString>
#include <QStringList>
#include <QTimer>
class QDBusServiceWatcher;
class QTimer;
namespace BlackMisc
{