mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Issue #11 CEventLoop uses QPointer trick to guard against use-after-free
See https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0
This commit is contained in:
@@ -182,7 +182,7 @@ namespace BlackCore
|
||||
|
||||
// with this little trick we try to make an asynchronous signal / slot based approach
|
||||
// a synchronous return value
|
||||
CEventLoop eventLoop;
|
||||
CEventLoop eventLoop(this);
|
||||
eventLoop.stopWhen(m_fsdClient, &CFSDClient::flightPlanReceived, [ = ](const auto &cs, const auto &) { return cs == callsign; });
|
||||
if (eventLoop.exec(1500))
|
||||
{
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace BlackCore
|
||||
CStatusMessageList CApplication::waitForSetup(int timeoutMs)
|
||||
{
|
||||
if (!m_setupReader) { return CStatusMessage(this).error(u"No setup reader"); }
|
||||
CEventLoop eventLoop;
|
||||
CEventLoop eventLoop(this);
|
||||
eventLoop.stopWhen(this, &CApplication::setupHandlingCompleted);
|
||||
if (!m_setupReader->isSetupAvailable())
|
||||
{
|
||||
@@ -435,6 +435,11 @@ namespace BlackCore
|
||||
|
||||
// setup handling completed with success or failure, or we run into time out
|
||||
CStatusMessageList msgs;
|
||||
if (!eventLoop.isGuardAlive())
|
||||
{
|
||||
msgs.push_back(CStatusMessage(this).error(u"Setup not available, already shutting down."));
|
||||
return msgs;
|
||||
}
|
||||
bool forced = false;
|
||||
if (!m_setupReader->isSetupAvailable())
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace BlackCore::Db
|
||||
{
|
||||
// just give the system some time to relax, consolidation is time consuming
|
||||
if (!this->doWorkCheck()) { return; }
|
||||
CEventLoop eventLoop;
|
||||
CEventLoop eventLoop(this);
|
||||
eventLoop.exec(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user