From a646e122af73801e6bc49631b9e29ab18f928dd3 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 25 May 2019 23:14:33 +0200 Subject: [PATCH] Avoid ASSERT from emulated driver * not all plugins are installed * use default simulator if there is no simulator info --- src/blackcore/context/contextsimulatorimpl.cpp | 15 ++++++++++++++- .../simulator/emulated/simulatoremulated.cpp | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 1e6dd02e6..27ad97dc6 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -447,7 +447,20 @@ namespace BlackCore this->setRemoteAircraftProvider(renderedAircraftProvider); // use simulator info from ISimulator as it can access the emulated driver settings - const CSimulatorInfo simInfo = simulator->getSimulatorInfo(); + CSimulatorInfo simInfo = simulator->getSimulatorInfo(); + if (!simInfo.isSingleSimulator()) + { + BLACK_VERIFY_X(false, Q_FUNC_INFO, "Invalid simulator from plugin"); + simInfo = CSimulatorInfo::p3d(); + if (simulator->isEmulatedDriver()) + { + CLogMessage(this).error(u"Emulated driver does NOT provide valid simulator, using default '%1', plugin: '%2'") << simInfo.toQString(true) << simulatorPluginInfo.toQString(true); + } + else + { + CLogMessage(this).error(u"Invalid driver using default '%1', plugin: '%2'") << simInfo.toQString(true) << simulatorPluginInfo.toQString(true); + } + } Q_ASSERT_X(simInfo.isSingleSimulator(), Q_FUNC_INFO, "need single simulator"); m_modelSetSimulator.set(simInfo); diff --git a/src/plugins/simulator/emulated/simulatoremulated.cpp b/src/plugins/simulator/emulated/simulatoremulated.cpp index 7b98cab38..dc4e1cf80 100644 --- a/src/plugins/simulator/emulated/simulatoremulated.cpp +++ b/src/plugins/simulator/emulated/simulatoremulated.cpp @@ -384,7 +384,11 @@ namespace BlackSimPlugin } else { - CLogMessage(this).validationError(u"No valid plugin for '%1'") << simulator.toQString(); + // not all drivers are installed + CLogMessage(this).validationError(u"No valid plugin in emulated driver for '%1'") << simulator.toQString(); + const QString sn = simulator.toQString(true); + const CSimulatorPluginInfo fakedPlugin = CSimulatorPluginInfo(simulator.toPluginIdentifier(), sn, sn, QStringLiteral("Emulated, but uninstalled '%1'").arg(sn), false); + this->setNewPluginInfo(fakedPlugin, settings.getDefaultModel()); } // update provider, own name, title