diff --git a/samples/blackmiscsim/samplesmodelmapping.cpp b/samples/blackmiscsim/samplesmodelmapping.cpp index 34f9c4650..90a70af44 100644 --- a/samples/blackmiscsim/samplesmodelmapping.cpp +++ b/samples/blackmiscsim/samplesmodelmapping.cpp @@ -68,7 +68,7 @@ namespace BlackSample // sync definitions, remove redundant ones CAircraftMatcher matcher; - matcher.setModelSet(vpRulesReader.getAsModelsFromCache(), CSimulatorInfo::FSX); + matcher.setModelSet(vpRulesReader.getAsModelsFromCache(), CSimulatorInfo::FSX, true); const CAircraftIcaoCode icao("C172"); streamOut << "Searching for " << icao << endl; diff --git a/src/blackcore/aircraftmatcher.cpp b/src/blackcore/aircraftmatcher.cpp index f139ef106..37bbfa678 100644 --- a/src/blackcore/aircraftmatcher.cpp +++ b/src/blackcore/aircraftmatcher.cpp @@ -517,8 +517,15 @@ namespace BlackCore return icao; } - int CAircraftMatcher::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator) + int CAircraftMatcher::setModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator, bool forced) { + if (!simulator.isSingleSimulator()) { return 0; } + if (!forced && m_simulator == simulator && m_modelSet.size() > 0) + { + // same simulator with models + return m_modelSet.size(); + } + CAircraftModelList modelsCleaned(models); const int r1 = modelsCleaned.removeAllWithoutModelString(); const int r2 = modelsCleaned.removeIfExcluded(); diff --git a/src/blackcore/aircraftmatcher.h b/src/blackcore/aircraftmatcher.h index 40f4d0c46..adf825e59 100644 --- a/src/blackcore/aircraftmatcher.h +++ b/src/blackcore/aircraftmatcher.h @@ -157,7 +157,7 @@ namespace BlackCore //! Set the models we want to use //! \note uses a set from "somewhere else" so it can also be used with arbitrary sets for testing - int setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator); + int setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator, bool forced); //! Default model const BlackMisc::Simulation::CAircraftModel &getDefaultModel() const { return m_defaultModel; } diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 3e1bed1c4..4b1acbca2 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -175,6 +175,9 @@ namespace BlackCore { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } const CSimulatorInfo simulator = m_modelSetSimulator.get(); + if (!simulator.isSingleSimulator()) { return CAircraftModelList(); } + + CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator); return CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator); } @@ -191,7 +194,7 @@ namespace BlackCore if (this->isSimulatorAvailable()) { return; } m_modelSetSimulator.set(simulator); const CAircraftModelList models = this->getModelSet(); - m_aircraftMatcher.setModelSet(models, simulator); + m_aircraftMatcher.setModelSet(models, simulator, false); } CSimulatorInfo CContextSimulator::simulatorsWithInitializedModelSet() const @@ -375,7 +378,7 @@ namespace BlackCore m_modelSetSimulator.set(simInfo); const CAircraftModelList modelSetModels = this->getModelSet(); - m_aircraftMatcher.setModelSet(modelSetModels, simInfo); + m_aircraftMatcher.setModelSet(modelSetModels, simInfo, true); m_aircraftMatcher.setDefaultModel(simulator->getDefaultModel()); bool c = connect(simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::onSimulatorStatusChanged); @@ -907,7 +910,7 @@ namespace BlackCore CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().synchronizeCache(simulator); const CAircraftModelList models(this->getModelSet()); CLogMessage(this).info("Init aircraft matcher with %1 models from set for '%2'") << models.size() << simulator.toQString(); - m_aircraftMatcher.setModelSet(models, simulator); + m_aircraftMatcher.setModelSet(models, simulator, false); } } // namespace } // namespace diff --git a/src/blackgui/components/modelmatchercomponent.cpp b/src/blackgui/components/modelmatchercomponent.cpp index 58b0634df..67764059d 100644 --- a/src/blackgui/components/modelmatchercomponent.cpp +++ b/src/blackgui/components/modelmatchercomponent.cpp @@ -96,7 +96,7 @@ namespace BlackGui { Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); const CAircraftModelList models = CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance().getCachedModels(simulator); - m_matcher.setModelSet(models, simulator); + m_matcher.setModelSet(models, simulator, true); this->redisplay(); }