mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Guarding QTimer::singelShot operations, avoid to access dangling pointers
This commit is contained in:
committed by
Roland Winklmeier
parent
b5ba4013dd
commit
1b8383bee1
@@ -119,8 +119,10 @@ namespace BlackCore
|
|||||||
if (m_network && sApp && !sApp->isShuttingDown())
|
if (m_network && sApp && !sApp->isShuttingDown())
|
||||||
{
|
{
|
||||||
// thread safe update of m_network
|
// thread safe update of m_network
|
||||||
|
const QPointer<CAirspaceMonitor> guard(this);
|
||||||
QTimer::singleShot(0, m_network, [ = ]
|
QTimer::singleShot(0, m_network, [ = ]
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
if (m_network) { m_network->addInterimPositionReceiver(callsign); }
|
if (m_network) { m_network->addInterimPositionReceiver(callsign); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -459,8 +461,10 @@ namespace BlackCore
|
|||||||
if (trial < 2 && !complete)
|
if (trial < 2 && !complete)
|
||||||
{
|
{
|
||||||
this->addReverseLookupMessage(callsign, "Wait for further data");
|
this->addReverseLookupMessage(callsign, "Wait for further data");
|
||||||
|
const QPointer<CAirspaceMonitor> guard(this);
|
||||||
QTimer::singleShot(1500, this, [ = ]()
|
QTimer::singleShot(1500, this, [ = ]()
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
this->sendReadyForModelMatching(callsign, trial + 1); // recursive
|
this->sendReadyForModelMatching(callsign, trial + 1); // recursive
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1179,7 +1179,12 @@ namespace BlackCore
|
|||||||
// and trigger read
|
// and trigger read
|
||||||
if (sApp->isInternetAccessible())
|
if (sApp->isInternetAccessible())
|
||||||
{
|
{
|
||||||
QTimer::singleShot(0, m_sharedInfoDataReader, [this]() { m_sharedInfoDataReader->read(); });
|
const QPointer<CWebDataServices> guard(this);
|
||||||
|
QTimer::singleShot(0, m_sharedInfoDataReader, [ = ]()
|
||||||
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
|
m_sharedInfoDataReader->read();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,12 @@ namespace BlackGui
|
|||||||
bool CConfigurationWizard::event(QEvent *event)
|
bool CConfigurationWizard::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
|
if (event->type() != QEvent::EnterWhatsThisMode) { return QDialog::event(event); }
|
||||||
QTimer::singleShot(0, this, [ = ] { sGui->showHelp(this); });
|
const QPointer<CConfigurationWizard> guard(this);
|
||||||
|
QTimer::singleShot(0, this, [ = ]
|
||||||
|
{
|
||||||
|
if (guard.isNull() || !sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
sGui->showHelp(this);
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,9 +87,10 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
ui->comp_SimulatorSelector->setValue(simulator);
|
ui->comp_SimulatorSelector->setValue(simulator);
|
||||||
ui->le_Simulator->setText(simulator.toQString(true));
|
ui->le_Simulator->setText(simulator.toQString(true));
|
||||||
QTimer::singleShot(500, [this]()
|
const QPointer<CDbOwnModelSetComponent> guard(this);
|
||||||
|
QTimer::singleShot(500, [ = ]()
|
||||||
{
|
{
|
||||||
if (!sApp || sApp->isShuttingDown()) { return; }
|
if (guard.isNull() || !sApp || sApp->isShuttingDown()) { return; }
|
||||||
this->updateViewToCurrentModels();
|
this->updateViewToCurrentModels();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDownloadDialog::showAndStartDownloading()
|
void CDownloadDialog::showAndStartDownloading()
|
||||||
{
|
{
|
||||||
QTimer::singleShot(0, this, [ = ] { ui->comp_Download->triggerDownloadingOfFiles(2500); });
|
const QPointer<CDownloadDialog> guard(this);
|
||||||
|
QTimer::singleShot(0, this, [ = ]
|
||||||
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
|
ui->comp_Download->triggerDownloadingOfFiles(2500);
|
||||||
|
});
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -659,8 +659,10 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (ui->cb_Heavy->isChecked())
|
if (ui->cb_Heavy->isChecked())
|
||||||
{
|
{
|
||||||
|
const QPointer<CFlightPlanComponent> guard(this);
|
||||||
QTimer::singleShot(10, this, [ = ]
|
QTimer::singleShot(10, this, [ = ]
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
ui->cb_Tcas->setChecked(false);
|
ui->cb_Tcas->setChecked(false);
|
||||||
this->buildPrefixIcaoSuffix();
|
this->buildPrefixIcaoSuffix();
|
||||||
});
|
});
|
||||||
@@ -671,8 +673,10 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (ui->cb_Tcas->isChecked())
|
if (ui->cb_Tcas->isChecked())
|
||||||
{
|
{
|
||||||
|
const QPointer<CFlightPlanComponent> guard(this);
|
||||||
QTimer::singleShot(10, this, [ = ]
|
QTimer::singleShot(10, this, [ = ]
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
ui->cb_Heavy->setChecked(false);
|
ui->cb_Heavy->setChecked(false);
|
||||||
this->buildPrefixIcaoSuffix();
|
this->buildPrefixIcaoSuffix();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -218,7 +218,12 @@ namespace BlackGui
|
|||||||
if (reply == QMessageBox::Yes)
|
if (reply == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
const CStatusMessage msg = CStatusMessage(this).info("Using existing file '%1'") << saveAsFile;
|
const CStatusMessage msg = CStatusMessage(this).info("Using existing file '%1'") << saveAsFile;
|
||||||
QTimer::singleShot(100, this, [ = ] { this->downloadedXSwiftBusFile(msg); });
|
const QPointer<CInstallXSwiftBusComponent> guard(this);
|
||||||
|
QTimer::singleShot(100, this, [ = ]
|
||||||
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
|
this->downloadedXSwiftBusFile(msg);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,7 +508,12 @@ namespace BlackGui
|
|||||||
|
|
||||||
// call this deferred, otherwise the values are overridden with any values
|
// call this deferred, otherwise the values are overridden with any values
|
||||||
// from the UI builder
|
// from the UI builder
|
||||||
QTimer::singleShot(500, this, &CViewBaseNonTemplate::settingsChanged);
|
const QPointer<CViewBaseNonTemplate> guard(this);
|
||||||
|
QTimer::singleShot(500, this, [ = ]()
|
||||||
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
|
CViewBaseNonTemplate::settingsChanged();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CViewBaseNonTemplate::getSettingsFileName(bool load) const
|
QString CViewBaseNonTemplate::getSettingsFileName(bool load) const
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
bool CSimulatorEmulated::connectTo()
|
bool CSimulatorEmulated::connectTo()
|
||||||
{
|
{
|
||||||
|
const QPointer<CSimulatorEmulated> guard(this);
|
||||||
QTimer::singleShot(1000, this, [ = ]
|
QTimer::singleShot(1000, this, [ = ]
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
this->emitSimulatorCombinedStatus();
|
this->emitSimulatorCombinedStatus();
|
||||||
m_monitorWidget->show();
|
m_monitorWidget->show();
|
||||||
});
|
});
|
||||||
@@ -439,8 +441,10 @@ namespace BlackSimPlugin
|
|||||||
void CSimulatorEmulatedListener::startImpl()
|
void CSimulatorEmulatedListener::startImpl()
|
||||||
{
|
{
|
||||||
if (this->isShuttingDown()) { return; }
|
if (this->isShuttingDown()) { return; }
|
||||||
|
const QPointer<CSimulatorEmulatedListener> guard(this);
|
||||||
QTimer::singleShot(2000, this, [ = ]
|
QTimer::singleShot(2000, this, [ = ]
|
||||||
{
|
{
|
||||||
|
if (guard.isNull()) { return; }
|
||||||
Q_ASSERT_X(this->getPluginInfo().isValid(), Q_FUNC_INFO, "Invalid plugin");
|
Q_ASSERT_X(this->getPluginInfo().isValid(), Q_FUNC_INFO, "Invalid plugin");
|
||||||
emit this->simulatorStarted(this->getPluginInfo());
|
emit this->simulatorStarted(this->getPluginInfo());
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "blackconfig/buildconfig.h"
|
#include "blackconfig/buildconfig.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QPointer>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace BlackConfig;
|
using namespace BlackConfig;
|
||||||
@@ -1004,7 +1005,12 @@ namespace BlackSimPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cleanup function, actually this should not be needed
|
// 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
|
// bye
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user