* improved setting of combox value, fixed wrong text
* do NOT emit signals when same index
* getOwnCallsign
* do NOT used cache FPs for own aircraft
This commit is contained in:
Klaus Basan
2019-07-07 00:42:37 +02:00
committed by Mat Sutcliffe
parent 891a058f17
commit ea7b3316c9
10 changed files with 52 additions and 12 deletions

View File

@@ -160,14 +160,17 @@ namespace BlackCore
// use cache, but not for own callsign (always reload)
if (m_flightPlanCache.contains(callsign)) { plan = m_flightPlanCache[callsign]; }
if (!plan.wasSentOrLoaded() || plan.timeDiffSentOrLoadedMs() > 30 * 1000)
const bool ownAircraft = this->getOwnCallsign() == callsign;
if (ownAircraft || !plan.wasSentOrLoaded() || plan.timeDiffSentOrLoadedMs() > 30 * 1000)
{
// outdated, or not in cache at all
// outdated, or not in cache at all, or NOT own aircraft
plan = CFlightPlan(); // reset
m_flightPlanCache.remove(callsign);
m_network->sendFlightPlanQuery(callsign);
// with this little trick we try to make an asynchronous signal / slot
// based approach a synchronous return value
const QTime waitForFlightPlan = QTime::currentTime().addMSecs(1000);
const QTime waitForFlightPlan = QTime::currentTime().addMSecs(1500);
while (sApp && QTime::currentTime() < waitForFlightPlan)
{
// process some other events and hope network answer is received already

View File

@@ -109,6 +109,12 @@ namespace BlackCore
return m_ownAircraft.getTransponder();
}
CCallsign CContextOwnAircraft::getOwnCallsign() const
{
QReadLocker l(&m_lockAircraft);
return m_ownAircraft.getCallsign();
}
CCoordinateGeodetic CContextOwnAircraft::getOwnAircraftPosition() const
{
QReadLocker l(&m_lockAircraft);

View File

@@ -81,6 +81,10 @@ namespace BlackCore
virtual ~CContextOwnAircraft() override;
// IOwnAircraftProvider overrides
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnCallsign
//! \ingroup ownaircraftprovider
virtual BlackMisc::Aviation::CCallsign getOwnCallsign() const override;
//! \copydoc BlackMisc::Simulation::IOwnAircraftProvider::getOwnAircraftPosition
//! \ingroup ownaircraftprovider
virtual BlackMisc::Geo::CCoordinateGeodetic getOwnAircraftPosition() const override;