Fix rare crash and swift not being notified about a failed plane adding

This fixes are rare case, that no XPMP plane could be created (no model
was found) and this was not signaled to swift.
This commit is contained in:
Roland Winklmeier
2018-07-27 17:13:17 +02:00
committed by Klaus Basan
parent dc9b2a42f7
commit ef8c7d7d1c
2 changed files with 13 additions and 10 deletions

View File

@@ -258,17 +258,20 @@ namespace XSwiftBus
id = XPMPCreatePlaneWithModelName(modelName.c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str(), getPlaneData, planeLoaded, static_cast<void *>(this));
}
if (id)
if (!id)
{
Plane *plane = new Plane(id, callsign, aircraftIcao, airlineIcao, livery, modelName);
m_planesByCallsign[callsign] = plane;
m_planesById[id] = plane;
// Create view menu item
CMenuItem planeViewMenuItem = m_followPlaneViewSubMenu.item(callsign, [this, callsign] { enableFollowPlaneView(callsign); });
m_followPlaneViewMenuItems[callsign] = planeViewMenuItem;
m_followPlaneViewSequence.push_back(callsign);
emitPlaneAddingFailed(callsign);
return;
}
Plane *plane = new Plane(id, callsign, aircraftIcao, airlineIcao, livery, modelName);
m_planesByCallsign[callsign] = plane;
m_planesById[id] = plane;
// Create view menu item
CMenuItem planeViewMenuItem = m_followPlaneViewSubMenu.item(callsign, [this, callsign] { enableFollowPlaneView(callsign); });
m_followPlaneViewMenuItems[callsign] = planeViewMenuItem;
m_followPlaneViewSequence.push_back(callsign);
}
void CTraffic::removePlane(const std::string &callsign)