Use "myself" QPointer with "sGui->processEventsToRefreshGui"

Rational: during "sGui->processEventsToRefreshGui" object can be deleted
This commit is contained in:
Klaus Basan
2019-02-26 00:42:07 +01:00
committed by Mat Sutcliffe
parent 0e916864cb
commit bd1ef5dfea
3 changed files with 9 additions and 4 deletions

View File

@@ -225,6 +225,7 @@ namespace BlackGui
if (!m_splashScreen) { return; } if (!m_splashScreen) { return; }
this->displaySplashMessage(m); this->displaySplashMessage(m);
this->processEventsToRefreshGui(); this->processEventsToRefreshGui();
if (!sGui) { return; }
} }
} }

View File

@@ -51,16 +51,18 @@ namespace BlackGui
m_angle = 0; m_angle = 0;
this->show(); this->show();
this->setEnabled(true); this->setEnabled(true);
QPointer<CLoadIndicator> myself(this);
if (m_timerId == -1) { m_timerId = startTimer(m_delayMs); } if (m_timerId == -1) { m_timerId = startTimer(m_delayMs); }
if (processEvents && sGui) if (processEvents && sGui)
{ {
sGui->processEventsToRefreshGui(); sGui->processEventsToRefreshGui();
if (!myself) { return -1; } // deleted in meantime (process events)
} }
const int stopId = m_currentId++; // copy const int stopId = m_currentId++; // copy
if (timeoutMs > 0) if (timeoutMs > 0)
{ {
QPointer<CLoadIndicator> myself(this);
QTimer::singleShot(timeoutMs, this, [ = ] QTimer::singleShot(timeoutMs, this, [ = ]
{ {
if (!myself) { return; } if (!myself) { return; }

View File

@@ -39,6 +39,7 @@
#include <Qt> #include <Qt>
#include <QtGlobal> #include <QtGlobal>
#include <QMessageBox> #include <QMessageBox>
#include <QPointer>
class QCloseEvent; class QCloseEvent;
class QEvent; class QEvent;
@@ -122,8 +123,9 @@ void SwiftGuiStd::performGracefulShutdown()
ui->comp_MainInfoArea->dockAllWidgets(); ui->comp_MainInfoArea->dockAllWidgets();
// allow some other parts to react // allow some other parts to react
if (!sGui) { return; } // overall shutdown const QPointer<SwiftGuiStd> myself(this);
sGui->processEventsToRefreshGui(); if (sGui) { sGui->processEventsToRefreshGui(); }
if (!sGui || !myself) { return; } // killed in meantime?
// tell context GUI is going down // tell context GUI is going down
if (sGui->getIContextApplication()) if (sGui->getIContextApplication())
@@ -132,7 +134,7 @@ void SwiftGuiStd::performGracefulShutdown()
} }
// allow some other parts to react // allow some other parts to react
sGui->processEventsToRefreshGui(); if (sGui) { sGui->processEventsToRefreshGui(); }
} }
void SwiftGuiStd::closeEvent(QCloseEvent *event) void SwiftGuiStd::closeEvent(QCloseEvent *event)