mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +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");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
||||||
this->m_caches.setCurrentSimulator(simulator);
|
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, &IAircraftModelLoader::loadingFinished, this, &IAircraftModelLoader::ps_loadFinished);
|
||||||
|
connect(&this->m_caches, &IMultiSimulatorModelCaches::cacheChanged, this, &IAircraftModelLoader::ps_cacheChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
IAircraftModelLoader::~IAircraftModelLoader()
|
IAircraftModelLoader::~IAircraftModelLoader()
|
||||||
@@ -49,7 +52,7 @@ namespace BlackMisc
|
|||||||
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
if (models.isEmpty()) { return CStatusMessage(this, CStatusMessage::SeverityInfo, "No data"); }
|
||||||
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator(); // support default values
|
const CSimulatorInfo sim = simulator.isSingleSimulator() ? simulator : this->getSimulator(); // support default values
|
||||||
CAircraftModelList allModels(this->m_caches.getSynchronizedCachedModels(sim));
|
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)
|
if (c > 0)
|
||||||
{
|
{
|
||||||
return this->setCachedModels(allModels, sim);
|
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
|
QStringList IAircraftModelLoader::getModelDirectoriesOrDefault() const
|
||||||
{
|
{
|
||||||
const QStringList mdirs = this->m_settings.getModelDirectoriesOrDefault(this->getSimulator());
|
const QStringList mdirs = this->m_settings.getModelDirectoriesOrDefault(this->getSimulator());
|
||||||
@@ -136,8 +144,9 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
if (mode.testFlag(CacheOnly))
|
if (mode.testFlag(CacheOnly))
|
||||||
{
|
{
|
||||||
// only cache, but we did not find any data
|
// only cache, but we did not find any data yet (still in progress?)
|
||||||
emit loadingFinished(false, this->getSimulator());
|
// here we rely on the cache load slot, no need to emit here
|
||||||
|
// an alternative was to sync cache here
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->startLoadingFromDisk(mode, modelConsolidation, directory);
|
this->startLoadingFromDisk(mode, modelConsolidation, directory);
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ namespace BlackMisc
|
|||||||
BlackMisc::CStatusMessage replaceOrAddCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo());
|
BlackMisc::CStatusMessage replaceOrAddCachedModels(const CAircraftModelList &models, const CSimulatorInfo &simulator = CSimulatorInfo());
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Parsing is finished
|
//! Parsing is finished or cache has been loaded
|
||||||
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -175,6 +175,9 @@ namespace BlackMisc
|
|||||||
protected slots:
|
protected slots:
|
||||||
//! Loading finished, also logs messages
|
//! Loading finished, also logs messages
|
||||||
void ps_loadFinished(bool success);
|
void ps_loadFinished(bool success);
|
||||||
|
|
||||||
|
//! A cache has been changed
|
||||||
|
void ps_cacheChanged(const CSimulatorInfo &simInfo);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // 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
|
bool CAircraftCfgParser::isLoadingFinished() const
|
||||||
{
|
{
|
||||||
return !m_parserWorker || m_parserWorker->isFinished();
|
return !m_parserWorker || m_parserWorker->isFinished();
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ namespace BlackMisc
|
|||||||
virtual void startLoadingFromDisk(LoadMode mode, const ModelConsolidation &modelConsolidation, const QString &directory) override;
|
virtual void startLoadingFromDisk(LoadMode mode, const ModelConsolidation &modelConsolidation, const QString &directory) override;
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private slots:
|
|
||||||
//! Cache changed
|
|
||||||
void ps_cacheChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Section within file
|
//! Section within file
|
||||||
enum FileSection
|
enum FileSection
|
||||||
|
|||||||
Reference in New Issue
Block a user