mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-26 02:35:38 +08:00
Ref T246, avoid unnecessary roundtrips if simulator did not change or is not applicable
This commit is contained in:
@@ -216,6 +216,7 @@ namespace BlackGui
|
|||||||
if (m_modelLoader)
|
if (m_modelLoader)
|
||||||
{
|
{
|
||||||
m_modelLoader->gracefulShutdown();
|
m_modelLoader->gracefulShutdown();
|
||||||
|
m_loaderConnections.disconnectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create loader, also synchronizes the caches
|
// create loader, also synchronizes the caches
|
||||||
@@ -224,14 +225,14 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CLogMessage(this).error("Failed to init model loader %1") << simulator.toQString();
|
CLogMessage(this).error("Failed to init model loader %1") << simulator.toQString();
|
||||||
m_modelLoader.reset();
|
m_modelLoader.reset();
|
||||||
|
m_loaderConnections.disconnectAll();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const bool c = connect(m_modelLoader.get(), &IAircraftModelLoader::loadingFinished,
|
const QMetaObject::Connection connection = connect(m_modelLoader.get(), &IAircraftModelLoader::loadingFinished, this, &CDbOwnModelsComponent::onOwnModelsLoadingFinished, Qt::QueuedConnection);
|
||||||
this, &CDbOwnModelsComponent::onOwnModelsLoadingFinished, Qt::QueuedConnection);
|
Q_ASSERT_X(connection, Q_FUNC_INFO, "Failed connect for model loader");
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect for model loader");
|
m_loaderConnections.append(connection);
|
||||||
Q_UNUSED(c);
|
|
||||||
this->setSaveFileName(simulator);
|
this->setSaveFileName(simulator);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/simulation/simulatorinfo.h"
|
#include "blackmisc/simulation/simulatorinfo.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
|
#include "blackmisc/connectionguard.h"
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -127,6 +128,7 @@ namespace BlackGui
|
|||||||
private:
|
private:
|
||||||
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::CConnectionGuard m_loaderConnections;
|
||||||
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
|
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< currently init to simulator
|
||||||
|
|
||||||
|
|||||||
@@ -370,6 +370,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbOwnModelSetComponent::changeSimulator(const CSimulatorInfo &simulator)
|
void CDbOwnModelSetComponent::changeSimulator(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
|
if (m_simulator == simulator) { return; } // avoid unnecessary signals
|
||||||
|
m_simulator = simulator;
|
||||||
m_modelSetLoader.setSimulator(simulator);
|
m_modelSetLoader.setSimulator(simulator);
|
||||||
ui->tvp_OwnModelSet->setSimulatorForLoading(simulator);
|
ui->tvp_OwnModelSet->setSimulatorForLoading(simulator);
|
||||||
ui->le_Simulator->setText(simulator.toQString(true));
|
ui->le_Simulator->setText(simulator.toQString(true));
|
||||||
@@ -388,8 +390,6 @@ namespace BlackGui
|
|||||||
void CDbOwnModelSetComponent::setSimulator(const CSimulatorInfo &simulator)
|
void CDbOwnModelSetComponent::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");
|
||||||
const CSimulatorInfo currentSimulator = m_modelSetLoader.getSimulator();
|
|
||||||
if (currentSimulator == simulator) { return; } // avoid unnecessary signals
|
|
||||||
this->changeSimulator(simulator);
|
this->changeSimulator(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ namespace BlackGui
|
|||||||
QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
|
QScopedPointer<CDbOwnModelSetFormDialog> m_modelSetFormDialog;
|
||||||
QScopedPointer<CFirstModelSetDialog> m_firstModelSet;
|
QScopedPointer<CFirstModelSetDialog> m_firstModelSet;
|
||||||
QScopedPointer<CCopyModelsFromOtherSwiftVersionsDialog> m_copyFromAnotherSwift;
|
QScopedPointer<CCopyModelsFromOtherSwiftVersionsDialog> m_copyFromAnotherSwift;
|
||||||
|
BlackMisc::Simulation::CSimulatorInfo m_simulator; //!< currently set simulator
|
||||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this };
|
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this };
|
||||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TDistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::distributorPreferencesChanged }; //!< distributor preferences
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TDistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::distributorPreferencesChanged }; //!< distributor preferences
|
||||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModel> m_modelSettings { this }; //!< settings for models
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TModel> m_modelSettings { this }; //!< settings for models
|
||||||
|
|||||||
Reference in New Issue
Block a user