From 07589e8219419271d6bb00851c2d091469ace882 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 19 Mar 2018 20:46:08 +0100 Subject: [PATCH] Avoid redundant update of model set ui * added changed simulator in signal * only changed once when cache changed --- src/blackcore/context/contextsimulator.h | 2 +- src/blackcore/context/contextsimulatorimpl.cpp | 5 +++-- src/blackcore/context/contextsimulatorproxy.cpp | 2 +- src/blackgui/components/mappingcomponent.cpp | 9 +++++---- src/blackgui/components/mappingcomponent.h | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index 550a98c87..b17ba17c0 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -95,7 +95,7 @@ namespace BlackCore void renderRestrictionsChanged(bool restricted, bool enabled, int maxAircraft, const BlackMisc::PhysicalQuantities::CLength &maxRenderedDistance); //! Model set ready or changed - void modelSetChanged(); + void modelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); //! A single model has been matched for given aircraft void modelMatchingCompleted(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 318fed537..ade8e5834 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -68,7 +68,8 @@ namespace BlackCore this->restoreSimulatorPlugins(); connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived); - connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CContextSimulator::modelSetChanged); + // seems to be redundant, as changed sim will cause changed cache + // connect(&m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDigestSignal::modelSetChanged); connect(&m_modelSetLoader, &CAircraftModelSetLoader::cacheChanged, this, &CContextSimulator::modelSetChanged); // deferred init of last model set, if no other data are set in meantime @@ -534,7 +535,7 @@ namespace BlackCore void CContextSimulator::onModelSetChanged(const CSimulatorInfo &simulator) { Q_UNUSED(simulator); - emit this->modelSetChanged(); + emit this->modelSetChanged(simulator); } void CContextSimulator::xCtxTextMessagesReceived(const Network::CTextMessageList &textMessages) diff --git a/src/blackcore/context/contextsimulatorproxy.cpp b/src/blackcore/context/contextsimulatorproxy.cpp index 6bf1ab9d2..b8c0625d1 100644 --- a/src/blackcore/context/contextsimulatorproxy.cpp +++ b/src/blackcore/context/contextsimulatorproxy.cpp @@ -51,7 +51,7 @@ namespace BlackCore "simulatorStatusChanged", this, SIGNAL(simulatorStatusChanged(int))); Q_ASSERT(s); s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), - "modelSetChanged", this, SIGNAL(modelSetChanged())); + "modelSetChanged", this, SIGNAL(modelSetChanged(BlackMisc::Simulation::CSimulatorInfo))); Q_ASSERT(s); s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), "ownAircraftModelChanged", this, SIGNAL(ownAircraftModelChanged(BlackMisc::Simulation::CAircraftModel))); diff --git a/src/blackgui/components/mappingcomponent.cpp b/src/blackgui/components/mappingcomponent.cpp index 64bcd5871..f426f4ae0 100644 --- a/src/blackgui/components/mappingcomponent.cpp +++ b/src/blackgui/components/mappingcomponent.cpp @@ -143,8 +143,9 @@ namespace BlackGui connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView); // with external core models might be already available - this->onModelSetSimulatorChanged(ui->comp_SimulatorSelector->getValue()); - this->onModelSetChanged(); + const CSimulatorInfo sim(ui->comp_SimulatorSelector->getValue()); + this->onModelSetSimulatorChanged(sim); + this->onModelSetChanged(sim); } CMappingComponent::~CMappingComponent() @@ -168,7 +169,7 @@ namespace BlackGui return ui->tvp_AircraftModels->container().findModelsStartingWith(modelName, cs); } - void CMappingComponent::onModelSetChanged() + void CMappingComponent::onModelSetChanged(const CSimulatorInfo &simulator) { if (ui->tvp_AircraftModels->displayAutomatically()) { @@ -176,7 +177,7 @@ namespace BlackGui } else { - CLogMessage(this).info("Models loaded, you can update the model view"); + CLogMessage(this).info("Model set loaded ('%1'), you can update the model view") << simulator.toQString(true); } // change completer diff --git a/src/blackgui/components/mappingcomponent.h b/src/blackgui/components/mappingcomponent.h index e6990dae6..aa2270f7e 100644 --- a/src/blackgui/components/mappingcomponent.h +++ b/src/blackgui/components/mappingcomponent.h @@ -79,9 +79,9 @@ namespace BlackGui private: //! Aircraft models available - void onModelSetChanged(); + void onModelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); - //! Changed count + //! Changed count of rendered or aircraft model count void onRowCountChanged(int count, bool withFilter); //! Simulated aircraft did change in view