Skip to content

Commit

Permalink
qt: Avoid splash-screen related memory leak
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laanwj committed Nov 23, 2016
1 parent 693384e commit e4f126a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/qt/bitcoin.cpp
Expand Up @@ -365,9 +365,8 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
{
SplashScreen *splash = new SplashScreen(0, networkStyle);
// We don't hold a direct pointer to the splash screen after creation, so use
// Qt::WA_DeleteOnClose to make sure that the window will be deleted eventually.
splash->setAttribute(Qt::WA_DeleteOnClose);
// We don't hold a direct pointer to the splash screen after creation, but the splash
// screen will take care of deleting itself when slotFinish happens.
splash->show();
connect(this, SIGNAL(splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
connect(this, SIGNAL(requestedShutdown()), splash, SLOT(close()));
Expand Down
1 change: 1 addition & 0 deletions src/qt/splashscreen.cpp
Expand Up @@ -147,6 +147,7 @@ void SplashScreen::slotFinish(QWidget *mainWin)
if (isMinimized())
showNormal();
hide();
deleteLater(); // No more need for this
}

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

0 comments on commit e4f126a

Please sign in to comment.