From 5299cfe371ddad806b1c4538d17cde069e25b1c1 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 27 Oct 2022 12:54:09 +0100 Subject: [PATCH 1/3] qt: Delete splash screen widget explicitly This ensures that during shutdown, including failed initialization, the `SplashScreen::m_connected_wallet_handlers` is deleted before the wallet context is. --- src/qt/bitcoin.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index cc01e4d54a..24af58a731 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -311,11 +311,8 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) { assert(!m_splash); m_splash = new SplashScreen(networkStyle); - // We don't hold a direct pointer to the splash screen after creation, but the splash - // screen will take care of deleting itself when finish() happens. m_splash->show(); connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish); - connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close); } void BitcoinApplication::createNode(interfaces::Init& init) @@ -373,6 +370,9 @@ void BitcoinApplication::requestShutdown() w->hide(); } + delete m_splash; + m_splash = nullptr; + // Show a simple window indicating shutdown status // Do this first as some of the steps may take some time below, // for example the RPC console may still be executing a command. @@ -412,10 +412,13 @@ void BitcoinApplication::requestShutdown() void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info) { qDebug() << __func__ << ": Initialization result: " << success; + // Set exit result. returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; - if(success) - { + if(success) { + delete m_splash; + m_splash = nullptr; + // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete qInfo() << "Platform customization:" << platformStyle->getName(); clientModel = new ClientModel(node(), optionsModel); @@ -438,7 +441,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead } else { window->showMinimized(); } - Q_EMIT splashFinished(); Q_EMIT windowShown(window); #ifdef ENABLE_WALLET @@ -455,7 +457,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead #endif pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY); } else { - Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown requestShutdown(); } } From 10811afff40efed1fda7eecab89884eaadd7146c Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 27 Oct 2022 12:54:23 +0100 Subject: [PATCH 2/3] qt: Drop no longer used `BitcoinApplication::splashFinished()` signal --- src/qt/bitcoin.cpp | 1 - src/qt/bitcoin.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 24af58a731..1bd7795a38 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -312,7 +312,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) assert(!m_splash); m_splash = new SplashScreen(networkStyle); m_splash->show(); - connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish); } void BitcoinApplication::createNode(interfaces::Init& init) diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 9ad37ca6c9..4f9eed5f49 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -89,7 +89,6 @@ public Q_SLOTS: Q_SIGNALS: void requestedInitialize(); void requestedShutdown(); - void splashFinished(); void windowShown(BitcoinGUI* window); protected: From 1b228497fa729c512a15bdfa80f61a610abfe8a5 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 27 Oct 2022 12:54:34 +0100 Subject: [PATCH 3/3] qt: Drop no longer used `SplashScreen::finish()` slot --- src/qt/splashscreen.cpp | 10 ---------- src/qt/splashscreen.h | 3 --- 2 files changed, 13 deletions(-) diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index bf04a6dd5f..e1692aeec7 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -161,16 +161,6 @@ bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) { return QObject::eventFilter(obj, ev); } -void SplashScreen::finish() -{ - /* If the window is minimized, hide() will be ignored. */ - /* Make sure we de-minimize the splashscreen window before hiding */ - if (isMinimized()) - showNormal(); - hide(); - deleteLater(); // No more need for this -} - static void InitMessage(SplashScreen *splash, const std::string &message) { bool invoked = QMetaObject::invokeMethod(splash, "showMessage", diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index c14fc521a7..0f7fb6bef8 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -37,9 +37,6 @@ protected: void closeEvent(QCloseEvent *event) override; public Q_SLOTS: - /** Hide the splash screen window and schedule the splash screen object for deletion */ - void finish(); - /** Show message and progress */ void showMessage(const QString &message, int alignment, const QColor &color);