Aircraft ICAO code of own model is wrong

Although the reverse lookup of a model is correct, it's aircraft ICAO code is wrong

Issues found

* in the driver the ICAO code is permanently overridden -> commented out
* there are two contexts, own aircraft and simulator, but only one uses reverse lookup -> now both
* using Qt::QueuedConnection for context -> GUI
This commit is contained in:
Klaus Basan
2018-12-11 00:51:31 +01:00
parent 7cf4a3ec33
commit c591728e88
5 changed files with 33 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
#include "blackcore/context/contextownaircraft.h"
#include "blackcore/context/contextownaircraftimpl.h"
#include "blackcore/context/contextsimulatorimpl.h"
#include "blackcore/db/databaseutils.h"
#include "blackcore/corefacade.h"
#include "blackcore/application.h"
#include "blackcore/pluginmanagersimulator.h"
@@ -43,6 +44,7 @@
#include <QPointer>
using namespace BlackConfig;
using namespace BlackCore::Db;
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
@@ -374,7 +376,7 @@ namespace BlackCore
Q_ASSERT(c);
c = connect(simulator, &ISimulator::physicallyAddingRemoteModelFailed, this, &CContextSimulator::onAddingRemoteAircraftFailed);
Q_ASSERT(c);
c = connect(simulator, &ISimulator::ownAircraftModelChanged, this, &IContextSimulator::ownAircraftModelChanged);
c = connect(simulator, &ISimulator::ownAircraftModelChanged, this, &CContextSimulator::onOwnSimulatorModelChanged);
Q_ASSERT(c);
c = connect(simulator, &ISimulator::aircraftRenderingChanged, this, &IContextSimulator::aircraftRenderingChanged);
Q_ASSERT(c);
@@ -960,6 +962,16 @@ namespace BlackCore
}
}
void CContextSimulator::onOwnSimulatorModelChanged(const CAircraftModel &model)
{
CAircraftModel lookupModel(model);
if (!lookupModel.isLoadedFromDb())
{
lookupModel = this->reverseLookupModel(model);
}
this->ownAircraftModelChanged(lookupModel);
}
void CContextSimulator::stopSimulatorListeners()
{
for (const CSimulatorPluginInfo &info : getAvailableSimulatorPlugins())
@@ -996,6 +1008,13 @@ namespace BlackCore
m_matchingMessages.remove(callsign);
}
CAircraftModel CContextSimulator::reverseLookupModel(const CAircraftModel &model)
{
bool modified = false;
const CAircraftModel reverseModel = CDatabaseUtils::consolidateOwnAircraftModelWithDbData(model, false, &modified);
return reverseModel;
}
void CContextSimulator::initByLastUsedModelSet()
{
// no models in matcher, but in cache, we can set them as default