From ef8c7d7d1cf76a8e11fdaca681c642b8deb09cb9 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 27 Jul 2018 17:13:17 +0200 Subject: [PATCH] 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. --- src/xswiftbus/libxplanemp | 2 +- src/xswiftbus/traffic.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/xswiftbus/libxplanemp b/src/xswiftbus/libxplanemp index 982162942..860edd58f 160000 --- a/src/xswiftbus/libxplanemp +++ b/src/xswiftbus/libxplanemp @@ -1 +1 @@ -Subproject commit 982162942ae672bff8364c145d059aae8f015f7e +Subproject commit 860edd58f0a8f2ae51506be92321b7998ba272b3 diff --git a/src/xswiftbus/traffic.cpp b/src/xswiftbus/traffic.cpp index 6f5a095a2..3b8431237 100644 --- a/src/xswiftbus/traffic.cpp +++ b/src/xswiftbus/traffic.cpp @@ -258,17 +258,20 @@ namespace XSwiftBus id = XPMPCreatePlaneWithModelName(modelName.c_str(), aircraftIcao.c_str(), airlineIcao.c_str(), livery.c_str(), getPlaneData, planeLoaded, static_cast(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)