mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
Delay initial weather injection until simulator is connected
Up to know, the initial weather injection was done in the constructor of ISimulator implementation. This was to early, since in the best case the injection was not doing anything and in the worst case, crashed the application because the plugin wasn't ready yet. This change also replaces ps_reloadSettings with a specific non-slot version to avoid code duplication.
This commit is contained in:
committed by
Mathew Sutcliffe
parent
e3fc72d775
commit
4e6c4a076a
@@ -110,7 +110,6 @@ namespace BlackSimPlugin
|
||||
));
|
||||
|
||||
resetData();
|
||||
ps_reloadSettings();
|
||||
}
|
||||
|
||||
// convert xplane squawk mode to swift squawk mode
|
||||
@@ -231,16 +230,6 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::ps_reloadSettings()
|
||||
{
|
||||
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isConnected() const
|
||||
{
|
||||
return m_service && m_traffic && m_weather;
|
||||
@@ -263,6 +252,7 @@ namespace BlackSimPlugin
|
||||
m_service->updateAirportsInRange();
|
||||
m_traffic->updateInstalledModels();
|
||||
m_watcher->setConnection(m_conn);
|
||||
reloadWeatherSettings();
|
||||
emitSimulatorCombinedStatus();
|
||||
return true;
|
||||
}
|
||||
@@ -646,6 +636,19 @@ namespace BlackSimPlugin
|
||||
m_weather->setThunderstormRatio(0.0);
|
||||
}
|
||||
|
||||
void CSimulatorXPlane::reloadWeatherSettings()
|
||||
{
|
||||
if (m_weather)
|
||||
{
|
||||
auto selectedWeatherScenario = m_weatherScenarioSettings.get();
|
||||
if (!CWeatherScenario::isRealWeatherScenario(selectedWeatherScenario))
|
||||
{
|
||||
m_lastWeatherPosition = {};
|
||||
injectWeatherGrid(CWeatherGrid::getByScenario(selectedWeatherScenario));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
|
||||
IOwnAircraftProvider *ownAircraftProvider,
|
||||
IRemoteAircraftProvider *remoteAircraftProvider,
|
||||
|
||||
@@ -134,12 +134,11 @@ namespace BlackSimPlugin
|
||||
void ps_fastTimerTimeout();
|
||||
void ps_slowTimerTimeout();
|
||||
void ps_installedModelsUpdated(const QStringList &modelStrings, const QStringList &icaos, const QStringList &airlines, const QStringList &liveries);
|
||||
void ps_reloadSettings();
|
||||
|
||||
|
||||
private:
|
||||
//! Inject weather grid to simulator
|
||||
void injectWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid);
|
||||
void reloadWeatherSettings();
|
||||
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
@@ -152,7 +151,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Simulation::CAircraftModelList m_installedModels; //!< \todo Do we still need this, as we now focus on model set
|
||||
|
||||
BlackMisc::Geo::CCoordinateGeodetic m_lastWeatherPosition; //!< Own aircraft position at which weather was fetched and injected last
|
||||
BlackMisc::CSetting<BlackCore::Simulator::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorXPlane::ps_reloadSettings };
|
||||
BlackMisc::CSetting<BlackCore::Simulator::TSelectedWeatherScenario> m_weatherScenarioSettings { this, &CSimulatorXPlane::reloadWeatherSettings };
|
||||
|
||||
//! \todo Add units to members? pitchDeg?, altitudeFt?
|
||||
struct // data is written by DBus async method callbacks
|
||||
|
||||
Reference in New Issue
Block a user