mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #649, further fixes and improvements
* call of non-virtual function in ctor * use getCopy * return number of merged models * change current simulator in model set loader (fixes infinite loop: change data -> signal -> change data).
This commit is contained in:
@@ -66,7 +66,7 @@ namespace BlackMisc
|
||||
{
|
||||
this->m_currentSimulator.synchronize();
|
||||
const CSimulatorInfo sim(this->m_currentSimulator.getCopy());
|
||||
this->syncronizeCache(sim);
|
||||
this->syncronizeCacheImpl(sim);
|
||||
const QString simStr(sim.toQString(true));
|
||||
CLogMessage(this).info("Initialized model caches to %1") << simStr;
|
||||
}
|
||||
@@ -125,6 +125,21 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
void CModelCaches::syncronizeCache(const CSimulatorInfo &simulator)
|
||||
{
|
||||
this->syncronizeCacheImpl(simulator);
|
||||
}
|
||||
|
||||
CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator");
|
||||
const CSimulatorInfo s = this->m_currentSimulator.getCopy();
|
||||
if (s == simulator) { return sameSimMsg; }
|
||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||
this->syncronizeCache(simulator);
|
||||
return m;
|
||||
}
|
||||
|
||||
void CModelCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
@@ -139,21 +154,11 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
CStatusMessage CModelCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
static const CStatusMessage sameSimMsg = CStatusMessage(this).info("Same simulator");
|
||||
const CSimulatorInfo s = this->m_currentSimulator.getCopy();
|
||||
if (s == simulator) { return sameSimMsg; }
|
||||
const BlackMisc::CStatusMessage m = this->m_currentSimulator.set(simulator);
|
||||
this->syncronizeCache(simulator);
|
||||
return m;
|
||||
}
|
||||
|
||||
CModelSetCaches::CModelSetCaches(QObject *parent) : IMultiSimulatorModelCaches(parent)
|
||||
{
|
||||
this->m_currentSimulator.synchronize();
|
||||
const CSimulatorInfo sim(this->m_currentSimulator.getCopy());
|
||||
this->syncronizeCache(sim);
|
||||
this->syncronizeCacheImpl(sim);
|
||||
const QString simStr(sim.toQString(true));
|
||||
CLogMessage(this).info("Initialized model set caches to %1") << simStr;
|
||||
}
|
||||
@@ -215,16 +220,7 @@ namespace BlackMisc
|
||||
|
||||
void CModelSetCaches::syncronizeCache(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
{
|
||||
case CSimulatorInfo::FS9: this->m_modelCacheFs9.synchronize(); break;
|
||||
case CSimulatorInfo::FSX: this->m_modelCacheFsx.synchronize(); break;
|
||||
case CSimulatorInfo::P3D: this->m_modelCacheP3D.synchronize(); break;
|
||||
case CSimulatorInfo::XPLANE: this->m_modelCacheXP.synchronize(); break;
|
||||
default:
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
}
|
||||
this->syncronizeCacheImpl(simulator);
|
||||
}
|
||||
|
||||
CStatusMessage CModelSetCaches::setCurrentSimulator(const CSimulatorInfo &simulator)
|
||||
@@ -236,6 +232,20 @@ namespace BlackMisc
|
||||
this->syncronizeCache(simulator);
|
||||
return m;
|
||||
}
|
||||
|
||||
void CModelSetCaches::syncronizeCacheImpl(const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
switch (simulator.getSimulator())
|
||||
{
|
||||
case CSimulatorInfo::FS9: this->m_modelCacheFs9.synchronize(); break;
|
||||
case CSimulatorInfo::FSX: this->m_modelCacheFsx.synchronize(); break;
|
||||
case CSimulatorInfo::P3D: this->m_modelCacheP3D.synchronize(); break;
|
||||
case CSimulatorInfo::XPLANE: this->m_modelCacheXP.synchronize(); break;
|
||||
default:
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -246,6 +246,9 @@ namespace BlackMisc
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheP3D> m_modelCacheP3D {this, &CModelCaches::changedP3D }; //!< P3D cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheXP> m_modelCacheXP {this, &CModelCaches::changedXP }; //!< XP cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||
|
||||
//! Non virtaul version (used in ctor)
|
||||
void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
};
|
||||
|
||||
//! Bundle of caches for model sets of all simulators
|
||||
@@ -274,6 +277,9 @@ namespace BlackMisc
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this, &CModelSetCaches::changedP3D }; //!< P3D cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheXP> m_modelCacheXP {this, &CModelSetCaches::changedXP }; //!< XP cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetLastSelection> m_currentSimulator { this }; //!< current simulator
|
||||
|
||||
//! Non virtaul version (used in ctor)
|
||||
void syncronizeCacheImpl(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user