From 2b07012e4f20beead995abed8508e6e77a4cb217 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 12 Apr 2014 19:34:19 +0200 Subject: [PATCH] refs #199, fixed issues 7-14 of https://dev.vatsim-germany.org/issues/199 On top fixed bug for core mode in main.cpp --- samples/blackgui/main.cpp | 2 +- samples/blackgui/mainwindow.cpp | 3 +-- samples/blackgui/mainwindow_init.cpp | 2 +- src/blackcore/context_application_base.cpp | 2 +- src/blackcore/context_runtime.cpp | 12 +++++++++--- src/blackcore/context_runtime.h | 6 +++--- src/blackcore/dbus_server.cpp | 4 ++-- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/samples/blackgui/main.cpp b/samples/blackgui/main.cpp index fa63cad92..42f80473c 100644 --- a/samples/blackgui/main.cpp +++ b/samples/blackgui/main.cpp @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) coreMode = intro.getCoreMode(); windowMode = intro.getWindowMode(); QString dbusAddress = BlackCore::CDBusServer::fixAddressToDBusAddress(intro.getDBusAddress()); - switch (windowMode) + switch (coreMode) { case GuiModes::CoreExternal: runtimeConfig = BlackCore::CRuntimeConfig::remote(dbusAddress); diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index 4c7c08ae5..bf2c55a7f 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -67,7 +67,7 @@ void MainWindow::gracefulShutdown() if (!this->m_init) return; this->m_init = false; if (this->m_rt->getIContextApplication()) - emit this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops); + this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops); // close info window if (this->m_infoWindow) @@ -522,7 +522,6 @@ void MainWindow::updateSimulatorData() ui->le_SimulatorHeading->setText(ownAircraft.getSituation().getHeading().toFormattedQString()); ui->le_SimulatorGroundSpeed->setText(ownAircraft.getSituation().getGroundSpeed().toFormattedQString()); - ui->le_SimulatorCom1Active->setText(ownAircraft.getCom1System().getFrequencyActive().toFormattedQString()); ui->le_SimulatorCom1Standby->setText(ownAircraft.getCom1System().getFrequencyStandby().toFormattedQString()); ui->le_SimulatorCom2Active->setText(ownAircraft.getCom2System().getFrequencyActive().toFormattedQString()); diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 738bcb2b2..c59578b3f 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -236,7 +236,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) this->initContextMenus(); // starting - emit this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts); + this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts); // do this as last statement, so it can be used as flag // whether init has been completed diff --git a/src/blackcore/context_application_base.cpp b/src/blackcore/context_application_base.cpp index 71661ef0e..910049771 100644 --- a/src/blackcore/context_application_base.cpp +++ b/src/blackcore/context_application_base.cpp @@ -9,7 +9,7 @@ using namespace BlackMisc; namespace BlackCore { - QList CContextApplicationBase::s_contexts = QList(); + QList CContextApplicationBase::s_contexts; QtMessageHandler CContextApplicationBase::s_oldHandler = nullptr; /* diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 74cf0cab5..8e6244195 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -483,31 +483,37 @@ namespace BlackCore CContextAudio *CRuntime::getCContextAudio() { + Q_ASSERT_X(!this->m_contextAudio || this->m_contextAudio->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextAudio); } - CContextAudio *CRuntime::getCContextAudio() const + const CContextAudio *CRuntime::getCContextAudio() const { + Q_ASSERT_X(!this->m_contextAudio || this->m_contextAudio->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextAudio); } CContextApplication *CRuntime::getCContextApplication() { + Q_ASSERT_X(!this->m_contextApplication || this->m_contextApplication->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextApplication); } - CContextApplication *CRuntime::getCContextApplication() const + const CContextApplication *CRuntime::getCContextApplication() const { + Q_ASSERT_X(!this->m_contextApplication || this->m_contextApplication->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextApplication); } CContextSimulator *CRuntime::getCContextSimulator() { + Q_ASSERT_X(!this->m_contextSimulator || this->m_contextSimulator->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextSimulator); } - CContextSimulator *CRuntime::getCContextSimulator() const + const CContextSimulator *CRuntime::getCContextSimulator() const { + Q_ASSERT_X(!this->m_contextSimulator || this->m_contextSimulator->usingLocalObjects(), "CCoreRuntime", "Cannot downcast to local object"); return static_cast(this->m_contextSimulator); } diff --git a/src/blackcore/context_runtime.h b/src/blackcore/context_runtime.h index 841494861..d1f237a4c 100644 --- a/src/blackcore/context_runtime.h +++ b/src/blackcore/context_runtime.h @@ -141,7 +141,7 @@ namespace BlackCore //! Context for application //! \remarks only applicable for local object - CContextApplication *getCContextApplication() const; + const CContextApplication *getCContextApplication() const; //! Context for audio //! \remarks only applicable for local object @@ -149,7 +149,7 @@ namespace BlackCore //! Context for audio //! \remarks only applicable for local object - CContextAudio *getCContextAudio() const; + const CContextAudio *getCContextAudio() const; //! Context for simulator //! \remarks only applicable for local object @@ -157,7 +157,7 @@ namespace BlackCore //! Context for simulator //! \remarks only applicable for local object - CContextSimulator *getCContextSimulator() const; + const CContextSimulator *getCContextSimulator() const; //! Init void init(const CRuntimeConfig &config); diff --git a/src/blackcore/dbus_server.cpp b/src/blackcore/dbus_server.cpp index 576aeb66d..d49d8defd 100644 --- a/src/blackcore/dbus_server.cpp +++ b/src/blackcore/dbus_server.cpp @@ -33,7 +33,7 @@ namespace BlackCore QDBusConnection con = QDBusConnection::sessionBus(); if (!con.registerService(CDBusServer::ServiceName)) { - qCritical() << this->m_busServer.lastError().message(); + qCritical() << con.lastError().message(); qFatal("Cannot register DBus service, server started? dbus-daemon.exe --session --address=tcp:host=192.168.0.133,port=45000"); } } @@ -45,7 +45,7 @@ namespace BlackCore QDBusConnection con = QDBusConnection::systemBus(); if (!con.registerService(CDBusServer::ServiceName)) { - qCritical() << this->m_busServer.lastError().message(); + qCritical() << con.lastError().message(); qFatal("Cannot register DBus service, server started? dbus-daemon.exe --system --address=tcp:host=192.168.0.133,port=45000"); } }