diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 88b73bc6c..b11c7fbe8 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -555,6 +555,20 @@ namespace BlackCore } } + void CContextSimulator::changeEnabledSimulators() + { + CSimulatorPluginInfo currentPluginInfo = m_simulatorPlugin.first; + const QStringList enabledSimulators = m_enabledSimulators.getThreadLocal(); + + // Unload the current plugin, if it is no longer enabled + if (!currentPluginInfo.isUnspecified() && !enabledSimulators.contains(currentPluginInfo.getIdentifier())) + { + unloadSimulatorPlugin(); + emit simulatorStatusChanged(ISimulator::Disconnected); + } + restoreSimulatorPlugins(); + } + void CContextSimulator::restoreSimulatorPlugins() { stopSimulatorListeners(); diff --git a/src/blackcore/context/contextsimulatorimpl.h b/src/blackcore/context/contextsimulatorimpl.h index 83e98a4df..81276eb35 100644 --- a/src/blackcore/context/contextsimulatorimpl.h +++ b/src/blackcore/context/contextsimulatorimpl.h @@ -172,6 +172,9 @@ namespace BlackCore void ps_relayStatusMessageToSimulator(const BlackMisc::CStatusMessage &message); private: + //! Handle a change in enabled simulators + void changeEnabledSimulators(); + //! Reads list of enabled simulators, starts listeners void restoreSimulatorPlugins(); @@ -204,7 +207,7 @@ namespace BlackCore BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this }; //!< load model set from caches QMap m_matchingMessages; BlackMisc::CSettingReadOnly m_messageSettings { this }; //!< settings for messages - BlackMisc::CSettingReadOnly m_enabledSimulators { this, &CContextSimulator::restoreSimulatorPlugins }; + BlackMisc::CSettingReadOnly m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators }; QString m_networkSessionId; //! Network session, if not connected empty bool m_initallyAddAircrafts = false; bool m_enableMatchingMessages = true; diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index f58fe113f..cc30cdd8e 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -46,7 +46,6 @@ namespace BlackGui private slots: //! Driver plugin enabled/disabled - //! \todo Unload plugin if user disables it while running void ps_pluginStateChanged(const QString &identifier, bool enabled); //! Apply max.aircraft