mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #273, runtime context
* added send status message for convenience * order in graceful shutdown
This commit is contained in:
@@ -444,18 +444,11 @@ namespace BlackCore
|
|||||||
Q_ASSERT(c);
|
Q_ASSERT(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect local simulator and settings
|
// connect local simulator and settings and load plugin
|
||||||
if (this->m_contextSettings)
|
if (this->m_contextSettings)
|
||||||
{
|
{
|
||||||
connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged);
|
connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged);
|
||||||
if (this->m_contextSimulator->loadSimulatorPluginFromSettings())
|
this->m_contextSimulator->loadSimulatorPluginFromSettings();
|
||||||
{
|
|
||||||
qDebug() << "Simulator driver loaded";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "No simulator driver loaded";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,26 +479,12 @@ namespace BlackCore
|
|||||||
if (this->m_dbusServer) this->m_dbusServer->unregisterAllObjects();
|
if (this->m_dbusServer) this->m_dbusServer->unregisterAllObjects();
|
||||||
|
|
||||||
// handle contexts
|
// handle contexts
|
||||||
if (this->getIContextApplication())
|
|
||||||
{
|
|
||||||
disconnect(this->getIContextApplication());
|
|
||||||
this->getIContextApplication()->setOutputRedirectionLevel(IContextApplication::RedirectNone);
|
|
||||||
this->getIContextApplication()->setStreamingForRedirectedOutputLevel(IContextApplication::RedirectNone);
|
|
||||||
IContextApplication::resetOutputRedirection();
|
|
||||||
this->getIContextApplication()->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->getIContextOwnAircraft())
|
|
||||||
{
|
|
||||||
disconnect(this->getIContextOwnAircraft());
|
|
||||||
this->getIContextOwnAircraft()->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->getIContextSimulator())
|
if (this->getIContextSimulator())
|
||||||
{
|
{
|
||||||
// TODO: disconnect from simulator
|
|
||||||
disconnect(this->getIContextSimulator());
|
disconnect(this->getIContextSimulator());
|
||||||
|
this->getIContextSimulator()->disconnectFrom();
|
||||||
this->getIContextSimulator()->deleteLater();
|
this->getIContextSimulator()->deleteLater();
|
||||||
|
this->m_contextSimulator = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// log off from network, if connected
|
// log off from network, if connected
|
||||||
@@ -514,28 +493,51 @@ namespace BlackCore
|
|||||||
disconnect(this->getIContextNetwork());
|
disconnect(this->getIContextNetwork());
|
||||||
this->getIContextNetwork()->disconnectFromNetwork();
|
this->getIContextNetwork()->disconnectFromNetwork();
|
||||||
this->getIContextNetwork()->deleteLater();
|
this->getIContextNetwork()->deleteLater();
|
||||||
|
this->m_contextNetwork = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->getIContextAudio())
|
if (this->getIContextAudio())
|
||||||
{
|
{
|
||||||
disconnect(this->getIContextAudio());
|
disconnect(this->getIContextAudio());
|
||||||
this->getIContextAudio()->deleteLater();
|
this->getIContextAudio()->deleteLater();
|
||||||
|
this->m_contextAudio = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->getIContextOwnAircraft())
|
||||||
|
{
|
||||||
|
disconnect(this->getIContextOwnAircraft());
|
||||||
|
this->getIContextOwnAircraft()->deleteLater();
|
||||||
|
this->m_contextOwnAircraft = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->getIContextSettings())
|
if (this->getIContextSettings())
|
||||||
{
|
{
|
||||||
disconnect(this->getIContextSettings());
|
disconnect(this->getIContextSettings());
|
||||||
this->getIContextSettings()->deleteLater();
|
this->getIContextSettings()->deleteLater();
|
||||||
|
this->m_contextSettings = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark contexts as invalid
|
if (this->getIContextApplication())
|
||||||
// objects are already scheduled for deletion
|
{
|
||||||
this->m_contextApplication = nullptr;
|
disconnect(this->getIContextApplication());
|
||||||
this->m_contextAudio = nullptr;
|
this->getIContextApplication()->setOutputRedirectionLevel(IContextApplication::RedirectNone);
|
||||||
this->m_contextNetwork = nullptr;
|
this->getIContextApplication()->setStreamingForRedirectedOutputLevel(IContextApplication::RedirectNone);
|
||||||
this->m_contextOwnAircraft = nullptr;
|
IContextApplication::resetOutputRedirection();
|
||||||
this->m_contextSettings = nullptr;
|
this->getIContextApplication()->deleteLater();
|
||||||
this->m_contextSimulator = nullptr;
|
this->m_contextApplication = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuntime::sendStatusMessage(const CStatusMessage &message)
|
||||||
|
{
|
||||||
|
if (!this->getIContextApplication()) return;
|
||||||
|
this->getIContextApplication()->sendStatusMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CRuntime::sendStatusMessages(const CStatusMessageList &messages)
|
||||||
|
{
|
||||||
|
if (!this->getIContextApplication()) return;
|
||||||
|
this->getIContextApplication()->sendStatusMessages(messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRuntime::disconnectLogSignals(const QString &name)
|
void CRuntime::disconnectLogSignals(const QString &name)
|
||||||
|
|||||||
@@ -2,10 +2,13 @@
|
|||||||
#define BLACKCORE_CONTEXT_RUNTIME_H
|
#define BLACKCORE_CONTEXT_RUNTIME_H
|
||||||
|
|
||||||
#include "blackcore/context_runtime_config.h"
|
#include "blackcore/context_runtime_config.h"
|
||||||
|
#include "blackmisc/statusmessagelist.h"
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMultiMap>
|
#include <QMultiMap>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
// forward declaration, see review
|
// forward declaration, see review
|
||||||
@@ -142,6 +145,14 @@ namespace BlackCore
|
|||||||
//! Clean up (will be connected to signal QCoreApplication::aboutToQuit)
|
//! Clean up (will be connected to signal QCoreApplication::aboutToQuit)
|
||||||
void gracefulShutdown();
|
void gracefulShutdown();
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::sendStatusMessage
|
||||||
|
//! \remarks fail safe
|
||||||
|
void sendStatusMessage(const BlackMisc::CStatusMessage &message);
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::sendStatusMessage
|
||||||
|
//! \remarks fail safe
|
||||||
|
void sendStatusMessages(const BlackMisc::CStatusMessageList &messages);
|
||||||
|
|
||||||
// ------- Context as interface, normal way to access a context
|
// ------- Context as interface, normal way to access a context
|
||||||
|
|
||||||
//! Context for network
|
//! Context for network
|
||||||
|
|||||||
Reference in New Issue
Block a user