mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
Ref T260, interpolator deferred init fix. Make sure lambda is not called when interpolator is deleted.
This commit is contained in:
committed by
Roland Winklmeier
parent
08c27338aa
commit
9fa3e415f5
@@ -43,19 +43,24 @@ namespace BlackMisc
|
|||||||
// normally when created m_cg is still null since there is no CG in the provider yet
|
// normally when created m_cg is still null since there is no CG in the provider yet
|
||||||
|
|
||||||
if (simEnvProvider) { this->setSimulationEnvironmentProvider(simEnvProvider); }
|
if (simEnvProvider) { this->setSimulationEnvironmentProvider(simEnvProvider); }
|
||||||
if (setupProvider) { this->setInterpolationSetupProvider(setupProvider); }
|
if (setupProvider) { this->setInterpolationSetupProvider(setupProvider); }
|
||||||
if (remoteAircraftProvider)
|
if (remoteAircraftProvider)
|
||||||
{
|
{
|
||||||
this->setRemoteAircraftProvider(remoteAircraftProvider);
|
this->setRemoteAircraftProvider(remoteAircraftProvider);
|
||||||
QTimer::singleShot(2500, [ = ]
|
QObject::connect(&m_initTimer, &QTimer::timeout, [ = ] { this->deferredInit(); });
|
||||||
{
|
m_initTimer.setSingleShot(true);
|
||||||
if (m_model.hasModelString()) { return; } // set in-between
|
m_initTimer.start(2500);
|
||||||
this->initCorrespondingModel();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
this->attachLogger(logger);
|
this->attachLogger(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Derived>
|
||||||
|
void CInterpolator<Derived>::deferredInit()
|
||||||
|
{
|
||||||
|
if (m_model.hasModelString()) { return; } // set in-between
|
||||||
|
this->initCorrespondingModel();
|
||||||
|
}
|
||||||
|
|
||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
bool CInterpolator<Derived>::verifyInterpolationSituations(const CAircraftSituation &oldest, const CAircraftSituation &newer, const CAircraftSituation &latest, const CInterpolationAndRenderingSetupPerCallsign &setup)
|
bool CInterpolator<Derived>::verifyInterpolationSituations(const CAircraftSituation &oldest, const CAircraftSituation &newer, const CAircraftSituation &latest, const CInterpolationAndRenderingSetupPerCallsign &setup)
|
||||||
{
|
{
|
||||||
@@ -268,15 +273,10 @@ namespace BlackMisc
|
|||||||
template<typename Derived>
|
template<typename Derived>
|
||||||
CAircraftParts CInterpolator<Derived>::getInterpolatedOrGuessedParts(qint64 currentTimeMsSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, CPartsStatus &partsStatus, bool log) const
|
CAircraftParts CInterpolator<Derived>::getInterpolatedOrGuessedParts(qint64 currentTimeMsSinceEpoch, const CInterpolationAndRenderingSetupPerCallsign &setup, CPartsStatus &partsStatus, bool log) const
|
||||||
{
|
{
|
||||||
CAircraftParts parts = this->getInterpolatedParts(currentTimeMsSinceEpoch, setup, partsStatus, log);
|
CAircraftParts parts;
|
||||||
|
if (setup.isAircraftPartsEnabled()) { parts = this->getInterpolatedParts(currentTimeMsSinceEpoch, setup, partsStatus, log); }
|
||||||
if (!partsStatus.isSupportingParts())
|
if (!partsStatus.isSupportingParts())
|
||||||
{
|
{
|
||||||
if (!m_model.hasModelString())
|
|
||||||
{
|
|
||||||
const CSimulatedAircraft aircraft = this->getAircraftInRangeForCallsign(m_callsign);
|
|
||||||
// m_model = aircraft.getModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if model has been thru model matching
|
// check if model has been thru model matching
|
||||||
if (m_model.hasModelString())
|
if (m_model.hasModelString())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
@@ -102,6 +103,7 @@ namespace BlackMisc
|
|||||||
PhysicalQuantities::CLength m_cg { 0, nullptr } ; //!< fetched once, stays constant
|
PhysicalQuantities::CLength m_cg { 0, nullptr } ; //!< fetched once, stays constant
|
||||||
Aviation::CAircraftSituation m_lastInterpolation { Aviation::CAircraftSituation::null() }; //!< latest interpolation
|
Aviation::CAircraftSituation m_lastInterpolation { Aviation::CAircraftSituation::null() }; //!< latest interpolation
|
||||||
CAircraftModel m_model; //!< corresponding model
|
CAircraftModel m_model; //!< corresponding model
|
||||||
|
qint64 m_situationsLastModifiedUsed { -1 }; //!< based on situations last updated
|
||||||
|
|
||||||
//! Equal double values?
|
//! Equal double values?
|
||||||
static bool doubleEpsilonEqual(double d1, double d2)
|
static bool doubleEpsilonEqual(double d1, double d2)
|
||||||
@@ -138,10 +140,14 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CInterpolationLogger *m_logger = nullptr;
|
CInterpolationLogger *m_logger = nullptr;
|
||||||
|
QTimer m_initTimer; //!< timer to init model, will be deleted when interpolator is deleted and cancel the call
|
||||||
|
|
||||||
//! Log parts
|
//! Log parts
|
||||||
void logParts(qint64 timestamp, const Aviation::CAircraftParts &parts, int partsNo, bool empty, bool log) const;
|
void logParts(qint64 timestamp, const Aviation::CAircraftParts &parts, int partsNo, bool empty, bool log) const;
|
||||||
|
|
||||||
|
//! Deferred init
|
||||||
|
void deferredInit();
|
||||||
|
|
||||||
Derived *derived() { return static_cast<Derived *>(this); }
|
Derived *derived() { return static_cast<Derived *>(this); }
|
||||||
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
const Derived *derived() const { return static_cast<const Derived *>(this); }
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user