mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +08:00
Ref T246, avoid endless reloading if simulator did not change in DB models component
This commit is contained in:
@@ -53,19 +53,22 @@ namespace BlackGui
|
|||||||
|
|
||||||
// Last selection isPinned -> no sync needed
|
// Last selection isPinned -> no sync needed
|
||||||
const CSimulatorInfo simulator(m_simulatorSelection.get());
|
const CSimulatorInfo simulator(m_simulatorSelection.get());
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
if (simulator.isSingleSimulator())
|
||||||
const bool success = this->initModelLoader(simulator);
|
|
||||||
if (success)
|
|
||||||
{
|
{
|
||||||
m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
|
const bool success = this->initModelLoader(simulator);
|
||||||
}
|
if (success)
|
||||||
else
|
{
|
||||||
{
|
m_modelLoader->startLoading(IAircraftModelLoader::CacheOnly);
|
||||||
CLogMessage(this).error("Init of model loader failed in component");
|
m_simulator = simulator;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLogMessage(this).error("Init of model loader failed in component");
|
||||||
|
}
|
||||||
|
ui->comp_SimulatorSelector->setValue(simulator);
|
||||||
|
ui->le_Simulator->setText(simulator.toQString());
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
|
||||||
ui->le_Simulator->setText(simulator.toQString());
|
|
||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorChanged);
|
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelsComponent::onSimulatorChanged);
|
||||||
|
|
||||||
// menu
|
// menu
|
||||||
@@ -102,7 +105,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->setSimulator(simulator);
|
this->setSimulator(simulator);
|
||||||
if (onlyIfNotEmpty && this->getOwnModelsCount() > 0) { return false; }
|
if (onlyIfNotEmpty && this->getOwnModelsCount() > 0) { return false; }
|
||||||
this->requestSimulatorModels(simulator, onlyIfNotEmpty ? IAircraftModelLoader::InBackgroundNoCache : IAircraftModelLoader::LoadInBackground);
|
const IAircraftModelLoader::LoadMode mode = onlyIfNotEmpty ? IAircraftModelLoader::InBackgroundNoCache : IAircraftModelLoader::LoadInBackground;
|
||||||
|
this->requestSimulatorModels(simulator, mode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +145,10 @@ namespace BlackGui
|
|||||||
void CDbOwnModelsComponent::setSimulator(const CSimulatorInfo &simulator)
|
void CDbOwnModelsComponent::setSimulator(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||||
|
if (m_simulator == simulator) { return; }
|
||||||
|
|
||||||
|
// changed simulator
|
||||||
|
m_simulator = simulator;
|
||||||
this->loadInstalledModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
|
this->loadInstalledModels(simulator, IAircraftModelLoader::InBackgroundWithCache);
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
ui->comp_SimulatorSelector->setValue(simulator);
|
||||||
ui->le_Simulator->setText(simulator.toQString());
|
ui->le_Simulator->setText(simulator.toQString());
|
||||||
@@ -246,6 +254,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
void CDbOwnModelsComponent::CLoadModelsMenu::customMenu(CMenuActions &menuActions)
|
||||||
{
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
|
||||||
// for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
|
// for the moment I use all sims, I could restrict to CSimulatorInfo::getLocallyInstalledSimulators();
|
||||||
const CSimulatorInfo sims = CSimulatorInfo::allSimulators();
|
const CSimulatorInfo sims = CSimulatorInfo::allSimulators();
|
||||||
const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
const bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ namespace BlackGui
|
|||||||
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
|
QScopedPointer<Ui::CDbOwnModelsComponent> ui;
|
||||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models, aka models on disk
|
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models, aka models on disk
|
||||||
BlackMisc::CDataReadOnly<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_simulatorSelection { this }; //!< last selection
|
BlackMisc::CDataReadOnly<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_simulatorSelection { this }; //!< last selection
|
||||||
|
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< currently init to simulator
|
||||||
|
|
||||||
//! Request own models
|
//! Request own models
|
||||||
void requestOwnModelsUpdate();
|
void requestOwnModelsUpdate();
|
||||||
|
|||||||
Reference in New Issue
Block a user