Skip to content

Commit c7d2458

Browse files
committed
qt: Delete splash screen widget early
1 parent 640eb77 commit c7d2458

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/qt/bitcoin.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,8 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
281281
{
282282
assert(!m_splash);
283283
m_splash = new SplashScreen(networkStyle);
284-
// We don't hold a direct pointer to the splash screen after creation, but the splash
285-
// screen will take care of deleting itself when finish() happens.
286284
m_splash->show();
287285
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
288-
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
289286
}
290287

291288
void BitcoinApplication::createNode(interfaces::Init& init)
@@ -381,6 +378,14 @@ void BitcoinApplication::requestShutdown()
381378
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
382379
{
383380
qDebug() << __func__ << ": Initialization result: " << success;
381+
382+
// If success, m_splash is no longer needed.
383+
// Otherwise, it must be deleted prior to requesting shutdown
384+
// to make sure the `SplashScreen::m_connected_wallet_handlers`
385+
// is deleted before the wallet context is.
386+
delete m_splash;
387+
m_splash = nullptr;
388+
384389
// Set exit result.
385390
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
386391
if(success)
@@ -407,7 +412,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
407412
} else {
408413
window->showMinimized();
409414
}
410-
Q_EMIT splashFinished();
411415
Q_EMIT windowShown(window);
412416

413417
#ifdef ENABLE_WALLET
@@ -424,7 +428,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
424428
#endif
425429
pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY);
426430
} else {
427-
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
428431
requestShutdown();
429432
}
430433
}

0 commit comments

Comments
 (0)