mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 21:56:43 +08:00
Guarding QTimer::singelShot operations, avoid to access dangling pointers
This commit is contained in:
committed by
Roland Winklmeier
parent
b5ba4013dd
commit
1b8383bee1
@@ -59,8 +59,10 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorEmulated::connectTo()
|
||||
{
|
||||
const QPointer<CSimulatorEmulated> guard(this);
|
||||
QTimer::singleShot(1000, this, [ = ]
|
||||
{
|
||||
if (guard.isNull()) { return; }
|
||||
this->emitSimulatorCombinedStatus();
|
||||
m_monitorWidget->show();
|
||||
});
|
||||
@@ -439,8 +441,10 @@ namespace BlackSimPlugin
|
||||
void CSimulatorEmulatedListener::startImpl()
|
||||
{
|
||||
if (this->isShuttingDown()) { return; }
|
||||
const QPointer<CSimulatorEmulatedListener> guard(this);
|
||||
QTimer::singleShot(2000, this, [ = ]
|
||||
{
|
||||
if (guard.isNull()) { return; }
|
||||
Q_ASSERT_X(this->getPluginInfo().isValid(), Q_FUNC_INFO, "Invalid plugin");
|
||||
emit this->simulatorStarted(this->getPluginInfo());
|
||||
});
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "blackconfig/buildconfig.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPointer>
|
||||
#include <type_traits>
|
||||
|
||||
using namespace BlackConfig;
|
||||
@@ -1004,7 +1005,12 @@ namespace BlackSimPlugin
|
||||
}
|
||||
|
||||
// cleanup function, actually this should not be needed
|
||||
QTimer::singleShot(100, this, &CSimulatorFsxCommon::physicallyRemoveAircraftNotInProvider);
|
||||
const QPointer<CSimulatorFsxCommon> guard(this);
|
||||
QTimer::singleShot(100, this, [ = ]
|
||||
{
|
||||
if (guard.isNull()) { return; }
|
||||
CSimulatorFsxCommon::physicallyRemoveAircraftNotInProvider();
|
||||
});
|
||||
|
||||
// bye
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user