Guarding QTimer::singelShot operations, avoid to access dangling pointers

This commit is contained in:
Klaus Basan
2018-04-14 23:16:55 +02:00
committed by Roland Winklmeier
parent b5ba4013dd
commit 1b8383bee1
10 changed files with 52 additions and 8 deletions

View File

@@ -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;