Ref T786, further checks (shutdown, empty values)

This commit is contained in:
Klaus Basan
2020-04-20 00:05:58 +02:00
committed by Mat Sutcliffe
parent 2156eb1831
commit 17cebfb8d3
4 changed files with 14 additions and 5 deletions

View File

@@ -174,7 +174,7 @@ namespace BlackCore
void ISimulator::reloadWeatherSettings()
{
// log crash info about weather
if (sApp && !sApp->isShuttingDown()) { CCrashHandler::instance()->crashAndLogAppendInfo(u"Simulator weather: " % boolToYesNo(m_isWeatherActivated)); }
if (this->isShuttingDown()) { CCrashHandler::instance()->crashAndLogAppendInfo(u"Simulator weather: " % boolToYesNo(m_isWeatherActivated)); }
if (!m_isWeatherActivated) { return; }
m_lastWeatherPosition.setNull();
const CWeatherScenario selectedWeatherScenario = m_weatherScenarioSettings.get();
@@ -196,7 +196,7 @@ namespace BlackCore
}
// log crash info about weather
if (sApp && !sApp->isShuttingDown()) { CCrashHandler::instance()->crashAndLogAppendInfo(selectedWeatherScenario.toQString(true)); }
if (this->isShuttingDown()) { CCrashHandler::instance()->crashAndLogAppendInfo(selectedWeatherScenario.toQString(true)); }
}
void ISimulator::clearAllRemoteAircraftData()
@@ -1384,7 +1384,7 @@ namespace BlackCore
const QPointer<ISimulator> myself(this);
QTimer::singleShot(t, this, [ = ]
{
if (myself.isNull() || myself->isShuttingDown()) { return; }
if (!myself || myself->isShuttingDown()) { return; }
this->displayLoggedSituationInSimulator(cs, stopLogging, times - 1);
});
}

View File

@@ -467,6 +467,8 @@ namespace BlackSimPlugin
void CSimulatorFs9::injectWeatherGrid(const CWeatherGrid &weatherGrid)
{
if (this->isShuttingDownOrDisconnected()) { return; }
if (weatherGrid.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");

View File

@@ -2395,6 +2395,8 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::injectWeatherGrid(const CWeatherGrid &weatherGrid)
{
if (this->isShuttingDownOrDisconnected()) { return; }
if (weatherGrid.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
@@ -2817,7 +2819,7 @@ namespace BlackSimPlugin
QPointer<CSimulatorFsxCommonListener> myself(this);
QTimer::singleShot(0, this, [ = ]
{
if (!myself) { return; }
if (!myself || !sApp || sApp->isShuttingDown()) { return; }
this->checkConnection();
});
}
@@ -2837,13 +2839,15 @@ namespace BlackSimPlugin
bool check = false;
if (isOk(result))
{
// if we can connect, but not dispatch, it can mean a previously started FSX/P3D
// blocks remote calls -> RESTART
for (int i = 0; !check && i < 3 && !this->isShuttingDown(); i++)
{
// result not always in first dispatch as we first have to obtain simulator name
result = SimConnect_CallDispatch(hSimConnect, CSimulatorFsxCommonListener::SimConnectProc, this);
if (isFailure(result)) { break; } // means serious failure
check = this->checkVersionAndSimulator();
if (!check) { sApp->processEventsFor(500); }
if (!check && sApp) { sApp->processEventsFor(500); }
}
}
SimConnect_Close(hSimConnect);

View File

@@ -897,8 +897,11 @@ namespace BlackSimPlugin
void CSimulatorXPlane::injectWeatherGrid(const CWeatherGrid &weatherGrid)
{
if (this->isShuttingDownOrDisconnected()) { return; }
if (weatherGrid.isEmpty()) { return; }
if (!CThreadUtils::isCurrentThreadObjectThread(this))
{
BLACK_VERIFY_X(!CBuildConfig::isLocalDeveloperDebugBuild(), Q_FUNC_INFO, "Wrong thread");
QPointer<CSimulatorXPlane> myself(this);
QTimer::singleShot(0, this, [ = ]