mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #283 Simulator context takes responsibility for connecting CAirspaceMonitor signals to ISimulator slots
This commit is contained in:
@@ -43,6 +43,9 @@ namespace BlackCore
|
||||
//! Destructor
|
||||
virtual ~CContextNetwork();
|
||||
|
||||
//! Airspace monitor accessible to other contexts
|
||||
CAirspaceMonitor *getAirspaceMonitor() const { return m_airspace; }
|
||||
|
||||
public slots: // IContextNetwork overrides
|
||||
|
||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||
|
||||
@@ -411,10 +411,6 @@ namespace BlackCore
|
||||
// only connect if simulator runs locally, no round trips
|
||||
if (this->m_contextNetwork && this->m_contextNetwork->usingLocalObjects())
|
||||
{
|
||||
c = connect(this->m_contextNetwork, &IContextNetwork::changedAircraftSituation,
|
||||
this->getCContextSimulator(), &CContextSimulator::ps_addAircraftSituation);
|
||||
Q_ASSERT(c);
|
||||
|
||||
c = connect(this->m_contextNetwork, &IContextNetwork::textMessagesReceived,
|
||||
this->getCContextSimulator(), &CContextSimulator::ps_textMessagesReceived);
|
||||
Q_ASSERT(c);
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
#include "context_ownaircraft.h"
|
||||
#include "context_settings.h"
|
||||
#include "context_application.h"
|
||||
#include "context_network_impl.h"
|
||||
#include "context_runtime.h"
|
||||
#include <QPluginLoader>
|
||||
#include <QLibrary>
|
||||
#include "context_runtime.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
@@ -176,6 +177,15 @@ namespace BlackCore
|
||||
qFatal("No application context or application context not local");
|
||||
}
|
||||
|
||||
CAirspaceMonitor *airspace = this->getRuntime()->getCContextNetwork()->getAirspaceMonitor();
|
||||
connect(airspace, &CAirspaceMonitor::addedAircraft, this, &CContextSimulator::ps_addRemoteAircraft);
|
||||
connect(airspace, &CAirspaceMonitor::changedAircraftSituation, this, &CContextSimulator::ps_addAircraftSituation);
|
||||
connect(airspace, &CAirspaceMonitor::removedAircraft, this, &CContextSimulator::ps_removeRemoteAircraft);
|
||||
for (const auto &aircraft : airspace->getAircraftInRange())
|
||||
{
|
||||
m_simulator->addRemoteAircraft(aircraft.getCallsign(), aircraft.getSituation());
|
||||
}
|
||||
|
||||
// apply latest settings
|
||||
this->settingsChanged(static_cast<uint>(IContextSettings::SettingsSimulator));
|
||||
|
||||
@@ -221,6 +231,12 @@ namespace BlackCore
|
||||
{
|
||||
if (m_simulator)
|
||||
{
|
||||
// depending on shutdown order, network might already have been deleted
|
||||
if (CContextNetwork *network = this->getRuntime()->getCContextNetwork())
|
||||
{
|
||||
network->getAirspaceMonitor()->QObject::disconnect(this);
|
||||
}
|
||||
|
||||
this->QObject::disconnect(m_simulator); // disconnect as receiver straight away
|
||||
m_simulator->disconnectFrom(); // disconnect from simulator
|
||||
m_simulator->deleteLater();
|
||||
|
||||
Reference in New Issue
Block a user