mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
#447, consider cache changed signal in order to avoid issue mentioned here
https://dev.vatsim-germany.org/issues/447#note-11
This commit is contained in:
@@ -30,7 +30,10 @@ namespace BlackMisc
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
||||
this->m_caches.setCurrentSimulator(simulator);
|
||||
|
||||
// first connect is an internal connection to log info about load status
|
||||
connect(this, &IAircraftModelLoader::loadingFinished, this, &IAircraftModelLoader::ps_loadFinished);
|
||||
connect(&this->m_caches, &IMultiSimulatorModelCaches::cacheChanged, this, &IAircraftModelLoader::ps_cacheChanged);
|
||||
}
|
||||
|
||||
IAircraftModelLoader::~IAircraftModelLoader()
|
||||
@@ -49,7 +52,7 @@ namespace BlackMisc
|
||||
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
||||
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator(); // support default values
|
||||
CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim));
|
||||
int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||
const int c = allModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||
if (c > 0)
|
||||
{
|
||||
return this->setCachedModels(allModels, sim);
|
||||
@@ -73,6 +76,11 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void IAircraftModelLoader::ps_cacheChanged(const CSimulatorInfo &simInfo)
|
||||
{
|
||||
emit this->loadingFinished(true, simInfo);
|
||||
}
|
||||
|
||||
QStringList IAircraftModelLoader::getModelDirectoriesOrDefault() const
|
||||
{
|
||||
const QStringList mdirs = this->m_settings.getModelDirectoriesOrDefault(this->getSimulator());
|
||||
@@ -136,8 +144,9 @@ namespace BlackMisc
|
||||
}
|
||||
if (mode.testFlag(CacheOnly))
|
||||
{
|
||||
// only cache, but we did not find any data
|
||||
emit loadingFinished(false, this->getSimulator());
|
||||
// only cache, but we did not find any data yet (still in progress?)
|
||||
// here we rely on the cache load slot, no need to emit here
|
||||
// an alternative was to sync cache here
|
||||
return;
|
||||
}
|
||||
this->startLoadingFromDisk(mode, modelConsolidation, directory);
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace BlackMisc
|
||||
BlackMisc::CStatusMessage replaceOrAddCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo());
|
||||
|
||||
signals:
|
||||
//! Parsing is finished
|
||||
//! Parsing is finished or cache has been loaded
|
||||
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
protected:
|
||||
@@ -175,6 +175,9 @@ namespace BlackMisc
|
||||
protected slots:
|
||||
//! Loading finished, also logs messages
|
||||
void ps_loadFinished(bool success);
|
||||
|
||||
//! A cache has been changed
|
||||
void ps_cacheChanged(const CSimulatorInfo &simInfo);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -125,14 +125,6 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftCfgParser::ps_cacheChanged()
|
||||
{
|
||||
if (this->hasCachedData())
|
||||
{
|
||||
emit this->loadingFinished(true, this->getSimulator());
|
||||
}
|
||||
}
|
||||
|
||||
bool CAircraftCfgParser::isLoadingFinished() const
|
||||
{
|
||||
return !m_parserWorker || m_parserWorker->isFinished();
|
||||
|
||||
@@ -64,10 +64,6 @@ namespace BlackMisc
|
||||
virtual void startLoadingFromDisk(LoadMode mode, const ModelConsolidation &modelConsolidation, const QString &directory) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Cache changed
|
||||
void ps_cacheChanged();
|
||||
|
||||
private:
|
||||
//! Section within file
|
||||
enum FileSection
|
||||
|
||||
Reference in New Issue
Block a user