From 2031ba3d8b8012f46a1b986ca455c517c4c4bdf8 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 8 Feb 2019 01:25:15 +0100 Subject: [PATCH] Ref T528, avoid crash (assert) if simulator object is not accessible (remote UI) Also disable some UI elements in that case + display an info --- .../simulator/fsxcommon/fsxsettingscomponent.cpp | 12 +++++++++++- .../simulator/fsxcommon/fsxsettingscomponent.ui | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp index fc0eba789..4cf86d607 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.cpp @@ -69,6 +69,7 @@ namespace BlackSimPlugin void CFsxSettingsComponent::refresh() { const CSimulatorFsxCommon *fsxOrP3D = this->getFsxOrP3DSimulator(); + const bool localSim = fsxOrP3D; if (fsxOrP3D) { ui->cb_TraceSimConnectCalls->setChecked(fsxOrP3D->isTracingSendId()); @@ -77,6 +78,12 @@ namespace BlackSimPlugin ui->cb_UseFsuipc->setChecked(fsxOrP3D->isFsuipcOpened()); } + ui->lbl_NoLocalSimulator->setVisible(!localSim); + ui->cb_TraceSimConnectCalls->setEnabled(localSim); + ui->cb_EnableTerrainProbe->setEnabled(localSim); + ui->cb_SBOffsets->setEnabled(localSim); + ui->cb_UseFsuipc->setEnabled(localSim); + const bool terrainProbe = CBuildConfig::isRunningOnWindowsNtPlatform() && (CBuildConfig::buildWordSize() == 32); ui->cb_EnableTerrainProbe->setEnabled(terrainProbe); ui->pb_CopyTerrainProbe->setVisible(terrainProbe); @@ -134,10 +141,13 @@ namespace BlackSimPlugin CSimulatorFsxCommon *CFsxSettingsComponent::getFsxOrP3DSimulator() const { - if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator() || !sGui->getISimulator()) { return nullptr; } + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return nullptr; } const CSimulatorPluginInfo plugin = sGui->getIContextSimulator()->getSimulatorPluginInfo(); if (plugin.isEmulatedPlugin()) { return nullptr; } // cast would fail + // ISimulator can only be obtained in local environment, not distributed UI + if (!sGui->hasSimulator()) { return nullptr; } + ISimulator *simulator = sGui->getISimulator().data(); if (!simulator || simulator->isEmulatedDriver()) { return nullptr; } if (!simulator->getSimulatorInfo().isFsxP3DFamily()) { return nullptr; } diff --git a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui index 9c88497db..e2d4f87d4 100644 --- a/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui +++ b/src/plugins/simulator/fsxcommon/fsxsettingscomponent.ui @@ -7,7 +7,7 @@ 0 0 254 - 147 + 174 @@ -109,6 +109,16 @@ + + + + Looks like you are running a remote GUI, these settings only work locally. Use core settings. + + + true + + +