mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Emulated driver: Use QPointer for widget as the widget can be deleted elsewhere as well
This commit is contained in:
committed by
Mat Sutcliffe
parent
3ffedd16ec
commit
b1d1880d43
@@ -48,7 +48,7 @@ namespace BlackSimPlugin
|
||||
this->onSettingsChanged(); // init from settings
|
||||
|
||||
m_myAircraft = this->getOwnAircraft(); // sync with provider
|
||||
m_monitorWidget.reset(new CSimulatorEmulatedMonitorDialog(this, sGui->mainApplicationWidget()));
|
||||
m_monitorWidget = new CSimulatorEmulatedMonitorDialog(this, sGui->mainApplicationWidget());
|
||||
|
||||
connect(qApp, &QApplication::aboutToQuit, this, &CSimulatorEmulated::closeMonitor);
|
||||
connect(sGui, &CGuiApplication::aboutToShutdown, this, &CSimulatorEmulated::closeMonitor, Qt::QueuedConnection);
|
||||
@@ -58,6 +58,17 @@ namespace BlackSimPlugin
|
||||
this->connectOwnSignals();
|
||||
}
|
||||
|
||||
CSimulatorEmulated::~CSimulatorEmulated()
|
||||
{
|
||||
if (m_monitorWidget)
|
||||
{
|
||||
// if the widget still exists, close and delete it
|
||||
m_monitorWidget->close();
|
||||
m_monitorWidget->deleteLater();
|
||||
m_monitorWidget.clear();
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::isTimeSynchronized() const
|
||||
{
|
||||
return m_timeSyncronized;
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <QMap>
|
||||
#include <QTimer>
|
||||
#include <QScopedPointer>
|
||||
#include <QPointer>
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
@@ -50,6 +50,9 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Network::IClientProvider *clientProvider,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSimulatorEmulated() override;
|
||||
|
||||
// functions implemented
|
||||
virtual bool isTimeSynchronized() const override;
|
||||
virtual bool connectTo() override;
|
||||
@@ -177,7 +180,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::PhysicalQuantities::CTime m_offsetTime;
|
||||
BlackMisc::Simulation::CSimulatedAircraft m_myAircraft; //!< represents own aircraft of simulator
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_renderedAircraft; //!< represents remote aircraft in simulator
|
||||
QScopedPointer<CSimulatorEmulatedMonitorDialog> m_monitorWidget; //!< parent will be main window, so we need to destroy widget when destroyed
|
||||
QPointer<CSimulatorEmulatedMonitorDialog> m_monitorWidget; //!< parent will be main window, so we need to destroy widget when destroyed
|
||||
BlackMisc::CConnectionGuard m_connectionGuard; //!< connected with provider
|
||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSwiftPlugin> m_pluginSettings { this, &CSimulatorEmulated::onSettingsChanged };
|
||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Simulation::CInterpolatorMultiWrapper> m_interpolators; //!< interpolators per callsign
|
||||
|
||||
Reference in New Issue
Block a user