diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 89b6abdf4..534820536 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -239,7 +239,7 @@ namespace BlackCore if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (this->isSimulatorAvailable()) { return; } m_modelSetSimulator.set(simulator); - const CAircraftModelList models = this->getModelSet(); + const CAircraftModelList models = this->getModelSet(); // cache synced m_aircraftMatcher.setModelSet(models, simulator, false); } @@ -451,7 +451,7 @@ namespace BlackCore Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator"); m_modelSetSimulator.set(simInfo); - const CAircraftModelList modelSetModels = this->getModelSet(); + const CAircraftModelList modelSetModels = this->getModelSet(); // synced m_aircraftMatcher.setModelSet(modelSetModels, simInfo, true); m_aircraftMatcher.setDefaultModel(simulator->getDefaultModel()); @@ -1152,7 +1152,7 @@ namespace BlackCore // no models in matcher, but in cache, we can set them as default const CSimulatorInfo simulator(m_modelSetSimulator.get()); CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator); - const CAircraftModelList models(this->getModelSet()); + const CAircraftModelList models(this->getModelSet()); //synced CLogMessage(this).info(u"Init aircraft matcher with %1 models from set for '%2'") << models.size() << simulator.toQString(); m_aircraftMatcher.setModelSet(models, simulator, false); } diff --git a/src/plugins/simulator/xplane/simulatorxplane.cpp b/src/plugins/simulator/xplane/simulatorxplane.cpp index 16dcfce8f..0223e83bf 100644 --- a/src/plugins/simulator/xplane/simulatorxplane.cpp +++ b/src/plugins/simulator/xplane/simulatorxplane.cpp @@ -327,12 +327,12 @@ namespace BlackSimPlugin if (isConnected()) { return true; } QString dbusAddress = m_xswiftbusServerSetting.getThreadLocal(); - if (BlackMisc::CDBusServer::isSessionOrSystemAddress(dbusAddress)) + if (CDBusServer::isSessionOrSystemAddress(dbusAddress)) { m_dBusConnection = connectionFromString(dbusAddress); m_dbusMode = Session; } - else if (BlackMisc::CDBusServer::isQtDBusAddress(dbusAddress)) + else if (CDBusServer::isQtDBusAddress(dbusAddress)) { m_dBusConnection = QDBusConnection::connectToPeer(dbusAddress, "xswiftbus"); if (! m_dBusConnection.isConnected()) { return false; } @@ -600,7 +600,15 @@ namespace BlackSimPlugin const qint64 now = QDateTime::currentMSecsSinceEpoch(); m_addingInProgressAircraft.insert(newRemoteAircraft.getCallsign(), now); const QString callsign = newRemoteAircraft.getCallsign().asString(); - const CAircraftModel aircraftModel = newRemoteAircraft.getModel(); + CAircraftModel aircraftModel = newRemoteAircraft.getModel(); + if (aircraftModel.getCallsign() != newRemoteAircraft.getCallsign()) + { + CLogMessage(this).warning(u"Model for '%1' has no callsign, maybe using a default model") << callsign; + aircraftModel.setCallsign(callsign); // fix callsign to avoid follow up issues + + // we could disable the aircraft? + } + const QString livery = aircraftModel.getLivery().getCombinedCode(); //! \todo livery resolution for XP m_trafficProxy->addPlane(callsign, aircraftModel.getModelString(), newRemoteAircraft.getAircraftIcaoCode().getDesignator(), @@ -799,7 +807,13 @@ namespace BlackSimPlugin for (const CXPlaneMPAircraft &xplaneAircraft : m_xplaneAircraftObjects) { const CCallsign callsign(xplaneAircraft.getCallsign()); - BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "missing callsign"); + const bool hasCallsign = !callsign.isEmpty(); + if (!hasCallsign) + { + // does not make sense to continue here + BLACK_VERIFY_X(false, Q_FUNC_INFO, "missing callsign"); + continue; + } planesTransponders.callsigns.push_back(callsign.asString()); planesTransponders.codes.push_back(xplaneAircraft.getAircraft().getTransponderCode()); @@ -901,10 +915,12 @@ namespace BlackSimPlugin void CSimulatorXPlane::requestRemoteAircraftDataFromXPlane(const CCallsignSet &callsigns) { if (callsigns.isEmpty()) { return; } - if (this->isShuttingDown()) { return; } + if (!m_trafficProxy || this->isShuttingDown()) { return; } const QStringList csStrings = callsigns.getCallsignStrings(); + QPointer myself(this); m_trafficProxy->getRemoteAircraftData(csStrings, [ = ](const QStringList & callsigns, const QDoubleList & latitudesDeg, const QDoubleList & longitudesDeg, const QDoubleList & elevationsMeters, const QDoubleList & verticalOffsetsMeters) { + if (!myself) { return; } this->updateRemoteAircraftFromSimulator(callsigns, latitudesDeg, longitudesDeg, elevationsMeters, verticalOffsetsMeters); }); }