Ref T786, make sure injectWeather is called in the correct thread

This commit is contained in:
Klaus Basan
2020-04-18 02:39:04 +02:00
committed by Mat Sutcliffe
parent cfc748420c
commit fbf63457c1
4 changed files with 52 additions and 12 deletions

View File

@@ -685,7 +685,7 @@ namespace BlackSimPlugin
aircraftSituation.setOnGround(dtb(simulatorOwnAircraft.simOnGround) ? CAircraftSituation::OnGround : CAircraftSituation::NotOnGround, CAircraftSituation::OutOnGroundOwnAircraft);
const CAircraftLights lights(dtb(simulatorOwnAircraft.lightStrobe), dtb(simulatorOwnAircraft.lightLanding), dtb(simulatorOwnAircraft.lightTaxi),
dtb(simulatorOwnAircraft.lightBeacon), dtb(simulatorOwnAircraft.lightNav), dtb(simulatorOwnAircraft.lightLogo));
dtb(simulatorOwnAircraft.lightBeacon), dtb(simulatorOwnAircraft.lightNav), dtb(simulatorOwnAircraft.lightLogo));
CAircraftEngineList engines;
const QList<bool> helperList
@@ -2393,8 +2393,21 @@ namespace BlackSimPlugin
}
}
void CSimulatorFsxCommon::injectWeatherGrid(const Weather::CWeatherGrid &weatherGrid)
void CSimulatorFsxCommon::injectWeatherGrid(const CWeatherGrid &weatherGrid)
{
if (this->isShuttingDownOrDisconnected()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
QPointer<CSimulatorFsxCommon> myself(this);
QTimer::singleShot(0, this, [ = ]
{
if (!myself) { return; }
myself->injectWeatherGrid(weatherGrid);
});
return;
}
// So far, there is only global weather
auto glob = weatherGrid.frontOrDefault();
glob.setIdentifier("GLOB");