diff --git a/src/blackcore/airspacemonitor.cpp b/src/blackcore/airspacemonitor.cpp index 3c5011f5d..d891dd6e3 100644 --- a/src/blackcore/airspacemonitor.cpp +++ b/src/blackcore/airspacemonitor.cpp @@ -206,24 +206,25 @@ namespace BlackCore QList CAirspaceMonitor::connectRemoteAircraftProviderSignals( QObject *receiver, - std::function situationSlot, - std::function partsSlot, - std::function removedAircraftSlot, - std::function aircraftSnapshotSlot + std::function situationFunction, + std::function partsFunction, + std::function removedAircraftFunction, + std::function aircraftSnapshotFunction ) { Q_ASSERT_X(receiver, Q_FUNC_INFO, "Missing receiver"); // bind does not allow to define connection type, so we use receiver as workaround - const QMetaObject::Connection c1 = connect(this, &CAirspaceMonitor::addedAircraftSituation, receiver, situationSlot); + const QMetaObject::Connection uc; // unconnected + const QMetaObject::Connection c1 = situationFunction ? connect(this, &CAirspaceMonitor::addedAircraftSituation, receiver, situationFunction) : uc; Q_ASSERT_X(c1, Q_FUNC_INFO, "connect failed"); - const QMetaObject::Connection c2 = connect(this, &CAirspaceMonitor::addedAircraftParts, receiver, partsSlot); + const QMetaObject::Connection c2 = partsFunction ? connect(this, &CAirspaceMonitor::addedAircraftParts, receiver, partsFunction) : uc; Q_ASSERT_X(c2, Q_FUNC_INFO, "connect failed"); - const QMetaObject::Connection c3 = connect(this, &CAirspaceMonitor::removedAircraft, receiver, removedAircraftSlot); + const QMetaObject::Connection c3 = removedAircraftFunction ? connect(this, &CAirspaceMonitor::removedAircraft, receiver, removedAircraftFunction) : uc; Q_ASSERT_X(c3, Q_FUNC_INFO, "connect failed"); - // trick is to use the Queued signal here + // trick is to use the Qt::QueuedConnection signal here // analyzer (own thread) -> airspaceAircraftSnapshot -> AirspaceMonitor -> airspaceAircraftSnapshot queued in main thread - const QMetaObject::Connection c4 = connect(m_analyzer, &CAirspaceAnalyzer::airspaceAircraftSnapshot, receiver, aircraftSnapshotSlot, Qt::QueuedConnection); + const QMetaObject::Connection c4 = aircraftSnapshotFunction ? connect(m_analyzer, &CAirspaceAnalyzer::airspaceAircraftSnapshot, receiver, aircraftSnapshotFunction, Qt::QueuedConnection) : uc; Q_ASSERT_X(c4, Q_FUNC_INFO, "connect failed"); return QList({ c1, c2, c3, c4}); } diff --git a/src/blackcore/airspacemonitor.h b/src/blackcore/airspacemonitor.h index adae729a1..63562c5dd 100644 --- a/src/blackcore/airspacemonitor.h +++ b/src/blackcore/airspacemonitor.h @@ -174,10 +174,10 @@ namespace BlackCore //! \copydoc BlackMisc::Simulation::IRemoteAircraftProvider::connectRemoteAircraftProviderSignals virtual QList connectRemoteAircraftProviderSignals( QObject *receiver, - std::function addedSituationSlot, - std::function addedPartsSlot, - std::function removedAircraftSlot, - std::function aircraftSnapshotSlot + std::function situationFunction, + std::function partsFunction, + std::function removedAircraftFunction, + std::function aircraftSnapshotFunction ) override; //! Analyzer