diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp index 383fa96e2..14d5b900b 100644 --- a/src/blackcore/simulator.cpp +++ b/src/blackcore/simulator.cpp @@ -684,14 +684,23 @@ namespace BlackCore // swift data if (sApp && sApp->hasWebDataServices()) { - connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbAllDataRead, this, &ISimulator::onSwiftDbAllDataRead, Qt::QueuedConnection); + connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbAllDataRead, this, &ISimulator::onSwiftDbAllDataRead, Qt::QueuedConnection); connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbAirportsRead, this, &ISimulator::onSwiftDbAirportsRead, Qt::QueuedConnection); connect(sApp->getWebDataServices(), &CWebDataServices::swiftDbModelMatchingEntitiesRead, this, &ISimulator::onSwiftDbModelMatchingEntitiesRead, Qt::QueuedConnection); } connect(sApp, &CApplication::aboutToShutdown, this, &ISimulator::unload, Qt::QueuedConnection); // provider - this->setNewPluginInfo(pluginInfo, m_multiSettings.getSettings(pluginInfo.getSimulatorInfo())); + if (pluginInfo.isEmulatedPlugin() && !pluginInfo.getSimulatorInfo().isSingleSimulator()) + { + // emulated driver with NO info yet + CLogMessage(this).info(u"Plugin '%1' with no simulator info yet, hope it will be set later") << pluginInfo.getIdentifier(); + } + else + { + // NORMAL CASE or plugin with info already set + this->setNewPluginInfo(pluginInfo, m_multiSettings.getSettings(pluginInfo.getSimulatorInfo())); + } // info data m_simulatorInternals.setSimulatorName(this->getSimulatorName()); diff --git a/src/blackmisc/simulation/settings/simulatorsettings.cpp b/src/blackmisc/simulation/settings/simulatorsettings.cpp index 31a5d2c5b..8dea9b177 100644 --- a/src/blackmisc/simulation/settings/simulatorsettings.cpp +++ b/src/blackmisc/simulation/settings/simulatorsettings.cpp @@ -11,6 +11,7 @@ #include "blackmisc/simulation/fscommon/fscommonutil.h" #include "blackmisc/simulation/xplane/xplaneutil.h" #include "blackmisc/simulation/flightgear/flightgearutil.h" +#include "blackmisc/verify.h" #include "blackmisc/stringutils.h" #include "blackconfig/buildconfig.h" #include @@ -195,7 +196,12 @@ namespace BlackMisc CSimulatorSettings CMultiSimulatorSettings::getSettings(const CSimulatorInfo &simulator) const { - Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); + if (!simulator.isSingleSimulator()) + { + // mostly happening with emulated driver, VERIFY for better debugging + BLACK_VERIFY_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator"); + return CSimulatorSettings(); + } switch (simulator.getSimulator()) { case CSimulatorInfo::FG: return m_simSettingsFG.get(); diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index bc0f2fd09..3be2f67f1 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -30,11 +30,11 @@ namespace BlackSimPlugin namespace Emulated { CSimulatorEmulated::CSimulatorEmulated(const CSimulatorPluginInfo &info, - IOwnAircraftProvider *ownAircraftProvider, + IOwnAircraftProvider *ownAircraftProvider, IRemoteAircraftProvider *remoteAircraftProvider, - IWeatherGridProvider *weatherGridProvider, - IClientProvider *clientProvider, - QObject *parent) : + IWeatherGridProvider *weatherGridProvider, + IClientProvider *clientProvider, + QObject *parent) : CSimulatorPluginCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, clientProvider, parent) { Q_ASSERT_X(sApp && sApp->getIContextSimulator(), Q_FUNC_INFO, "Need context"); @@ -45,8 +45,8 @@ namespace BlackSimPlugin m_myAircraft = this->getOwnAircraft(); // sync with provider m_monitorWidget.reset(new CSimulatorEmulatedMonitorDialog(this, sGui->mainApplicationWidget())); - connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor); - connect(sGui, &CGuiApplication::aboutToShutdown, this, &CSimulatorEmulated::closeMonitor, Qt::QueuedConnection); + connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor); + connect(sGui, &CGuiApplication::aboutToShutdown, this, &CSimulatorEmulated::closeMonitor, Qt::QueuedConnection); connect(&m_interpolatorFetchTimer, &QTimer::timeout, this, &CSimulatorEmulated::updateRemoteAircraft); // connect own signals for monitoring @@ -281,7 +281,7 @@ namespace BlackSimPlugin bool CSimulatorEmulated::isConnected() const { - if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO); + if (canLog()) { m_monitorWidget->appendReceivingCall(Q_FUNC_INFO); } return m_connected; } diff --git a/src/plugins/simulator/emulated/simulatoremulated.h b/src/plugins/simulator/emulated/simulatoremulated.h index cc293be90..8cdaae617 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.h +++ b/src/plugins/simulator/emulated/simulatoremulated.h @@ -43,10 +43,10 @@ namespace BlackSimPlugin //! Constructor, parameters as in \sa BlackCore::ISimulatorFactory::create CSimulatorEmulated( const BlackMisc::Simulation::CSimulatorPluginInfo &info, - BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, + BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider, BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider, - BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, - BlackMisc::Network::IClientProvider *clientProvider, + BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider, + BlackMisc::Network::IClientProvider *clientProvider, QObject *parent = nullptr); // functions implemented @@ -125,7 +125,7 @@ namespace BlackSimPlugin protected: virtual bool physicallyAddRemoteAircraft(const BlackMisc::Simulation::CSimulatedAircraft &remoteAircraft) override; virtual bool physicallyRemoveRemoteAircraft(const BlackMisc::Aviation::CCallsign &callsign) override; - virtual int physicallyRemoveAllRemoteAircraft() override; + virtual int physicallyRemoveAllRemoteAircraft() override; //! \copydoc BlackCore::ISimulator::parseDetails virtual bool parseDetails(const BlackMisc::CSimpleCommandParser &parser) override; @@ -170,7 +170,6 @@ namespace BlackSimPlugin QScopedPointer m_monitorWidget; //!< parent will be main window, so we need to destroy widget when destroyed BlackMisc::CConnectionGuard m_connectionGuard; //!< connected with provider BlackMisc::CSettingReadOnly m_pluginSettings { this, &CSimulatorEmulated::onSettingsChanged }; - BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_multiSettings { this }; QMap m_interpolators; //!< interpolators per callsign };