Skip to content

Commit e4f126a

Browse files
committed
qt: Avoid splash-screen related memory leak
Make splash screen queue its own deletion when it receives the finished command, instead of relying on WA_DeleteOnClose which doesn't work under these circumstances.
1 parent 693384e commit e4f126a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/qt/bitcoin.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,8 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
365365
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
366366
{
367367
SplashScreen *splash = new SplashScreen(0, networkStyle);
368-
// We don't hold a direct pointer to the splash screen after creation, so use
369-
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
370-
splash->setAttribute(Qt::WA_DeleteOnClose);
368+
// We don't hold a direct pointer to the splash screen after creation, but the splash
369+
// screen will take care of deleting itself when slotFinish happens.
371370
splash->show();
372371
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
373372
connect(this, SIGNAL(requestedShutdown()), splash, SLOT(close()));

src/qt/splashscreen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ void SplashScreen::slotFinish(QWidget *mainWin)
147147
if (isMinimized())
148148
showNormal();
149149
hide();
150+
deleteLater(); // No more need for this
150151
}
151152

152153
static void InitMessage(SplashScreen *splash, const std::string &message)

0 commit comments

Comments
 (0)