Ref T232 clear remote aircraft data once network disconnects

* blackconfig in .pro
* verify function to detect dangling states
* clear remote data when disconnected from network
* there was one problem that the data where not correctly cleaned up and hence new aircraft where not added again after a disconnect/reconnect from network
* it is not yet clear why data happens (dangling data), that is what the debugVerify function is for
This commit is contained in:
Klaus Basan
2018-01-22 05:07:00 +01:00
parent 5f7842163b
commit d118ea402f
13 changed files with 98 additions and 34 deletions

View File

@@ -115,6 +115,9 @@ namespace BlackCore
//! A weather grid, requested with requestWeatherGrid(), is received
void weatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
//! Relevant simulator messages to be explicitly displayed
void driverMessages(const BlackMisc::CStatusMessageList &messages);
public slots:
//! Simulator info, currently loaded plugin
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const = 0;

View File

@@ -299,6 +299,8 @@ namespace BlackCore
Q_ASSERT(c);
c = connect(simulator, &ISimulator::airspaceSnapshotHandled, this, &IContextSimulator::airspaceSnapshotHandled);
Q_ASSERT(c);
c = connect(simulator, &ISimulator::driverMessages, this, &IContextSimulator::driverMessages);
Q_ASSERT(c);
// log from context to simulator
c = connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, &CContextSimulator::relayStatusMessageToSimulator);
@@ -504,11 +506,19 @@ namespace BlackCore
{
m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId();
}
else if (!m_networkSessionId.isEmpty())
else if (INetwork::isDisconnectedStatus(to))
{
m_networkSessionId.clear();
m_aircraftMatcher.clearMatchingStatistics();
m_matchingMessages.clear();
// check in case the plugin has been unloaded
if (m_simulatorPlugin.second)
{
const CStatusMessageList verifyMessages = m_simulatorPlugin.second->debugVerifyStateAfterAllAircraftRemoved();
m_simulatorPlugin.second->clearAllRemoteAircraftData();
if (!verifyMessages.isEmpty()) { emit this->driverMessages(verifyMessages); }
}
}
}

View File

@@ -225,7 +225,7 @@ namespace BlackCore
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages;
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
QString m_networkSessionId; //! Network session of CServer, if not connected empty
QString m_networkSessionId; //! Network session of CServer::getServerSessionId, if not connected empty
bool m_initallyAddAircrafts = false;
bool m_enableMatchingMessages = true;
bool m_isWeatherActivated = false;

View File

@@ -74,6 +74,10 @@ namespace BlackCore
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"addingRemoteModelFailed", this, SIGNAL(addingRemoteModelFailed(BlackMisc::Simulation::CSimulatedAircraft, BlackMisc::CStatusMessage)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"driverMessages", this, SIGNAL(driverMessages(BlackMisc::CStatusMessageList)));
Q_ASSERT(s);
Q_UNUSED(s);
this->relayBaseClassSignals(serviceName, connection, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName());
}