mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +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
|
//! Destructor
|
||||||
virtual ~CContextNetwork();
|
virtual ~CContextNetwork();
|
||||||
|
|
||||||
|
//! Airspace monitor accessible to other contexts
|
||||||
|
CAirspaceMonitor *getAirspaceMonitor() const { return m_airspace; }
|
||||||
|
|
||||||
public slots: // IContextNetwork overrides
|
public slots: // IContextNetwork overrides
|
||||||
|
|
||||||
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
//! \copydoc IContextNetwork::readAtcBookingsFromSource()
|
||||||
|
|||||||
@@ -411,10 +411,6 @@ namespace BlackCore
|
|||||||
// only connect if simulator runs locally, no round trips
|
// only connect if simulator runs locally, no round trips
|
||||||
if (this->m_contextNetwork && this->m_contextNetwork->usingLocalObjects())
|
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,
|
c = connect(this->m_contextNetwork, &IContextNetwork::textMessagesReceived,
|
||||||
this->getCContextSimulator(), &CContextSimulator::ps_textMessagesReceived);
|
this->getCContextSimulator(), &CContextSimulator::ps_textMessagesReceived);
|
||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
|
|||||||
@@ -7,9 +7,10 @@
|
|||||||
#include "context_ownaircraft.h"
|
#include "context_ownaircraft.h"
|
||||||
#include "context_settings.h"
|
#include "context_settings.h"
|
||||||
#include "context_application.h"
|
#include "context_application.h"
|
||||||
|
#include "context_network_impl.h"
|
||||||
|
#include "context_runtime.h"
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include "context_runtime.h"
|
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::PhysicalQuantities;
|
using namespace BlackMisc::PhysicalQuantities;
|
||||||
@@ -176,6 +177,15 @@ namespace BlackCore
|
|||||||
qFatal("No application context or application context not local");
|
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
|
// apply latest settings
|
||||||
this->settingsChanged(static_cast<uint>(IContextSettings::SettingsSimulator));
|
this->settingsChanged(static_cast<uint>(IContextSettings::SettingsSimulator));
|
||||||
|
|
||||||
@@ -221,6 +231,12 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (m_simulator)
|
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
|
this->QObject::disconnect(m_simulator); // disconnect as receiver straight away
|
||||||
m_simulator->disconnectFrom(); // disconnect from simulator
|
m_simulator->disconnectFrom(); // disconnect from simulator
|
||||||
m_simulator->deleteLater();
|
m_simulator->deleteLater();
|
||||||
|
|||||||
Reference in New Issue
Block a user