Skip to content

Commit 497f265

Browse files
committed
Merge #605: Delete splash screen widget early
1b22849 qt: Drop no longer used `SplashScreen::finish()` slot (Hennadii Stepanov) 10811af qt: Drop no longer used `BitcoinApplication::splashFinished()` signal (Hennadii Stepanov) 5299cfe qt: Delete splash screen widget explicitly (Hennadii Stepanov) Pull request description: Fixes #604. Fixes bitcoin/bitcoin#25146. Fixes bitcoin/bitcoin#26340. `SplashScreen::deleteLater()` [does not guarantee](https://doc.qt.io/qt-5/qobject.html#deleteLater) deletion of the `m_splash` object prior to the wallet context deletion. If the latter happens first, the [segfault](#604 (comment)) follows. ACKs for top commit: dooglus: ACK 1b22849 furszy: ACK 1b22849 john-moffett: ACK 1b22849 Tree-SHA512: bb01d0bf2051f5b184dc415c4f5d32dfb7b8bd772feff7ec7754ded4c6482de27f004b9712df7d53c5ee82e153f48aef4372e4a49d7bcbbb137f73e9b4947962
2 parents dcdfd72 + 1b22849 commit 497f265

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

src/qt/bitcoin.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,11 +311,7 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
311311
{
312312
assert(!m_splash);
313313
m_splash = new SplashScreen(networkStyle);
314-
// We don't hold a direct pointer to the splash screen after creation, but the splash
315-
// screen will take care of deleting itself when finish() happens.
316314
m_splash->show();
317-
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
318-
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
319315
}
320316

321317
void BitcoinApplication::createNode(interfaces::Init& init)
@@ -373,6 +369,9 @@ void BitcoinApplication::requestShutdown()
373369
w->hide();
374370
}
375371

372+
delete m_splash;
373+
m_splash = nullptr;
374+
376375
// Show a simple window indicating shutdown status
377376
// Do this first as some of the steps may take some time below,
378377
// for example the RPC console may still be executing a command.
@@ -412,10 +411,13 @@ void BitcoinApplication::requestShutdown()
412411
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
413412
{
414413
qDebug() << __func__ << ": Initialization result: " << success;
414+
415415
// Set exit result.
416416
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
417-
if(success)
418-
{
417+
if(success) {
418+
delete m_splash;
419+
m_splash = nullptr;
420+
419421
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
420422
qInfo() << "Platform customization:" << platformStyle->getName();
421423
clientModel = new ClientModel(node(), optionsModel);
@@ -438,7 +440,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
438440
} else {
439441
window->showMinimized();
440442
}
441-
Q_EMIT splashFinished();
442443
Q_EMIT windowShown(window);
443444

444445
#ifdef ENABLE_WALLET
@@ -455,7 +456,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
455456
#endif
456457
pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY);
457458
} else {
458-
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
459459
requestShutdown();
460460
}
461461
}

src/qt/bitcoin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ public Q_SLOTS:
8989
Q_SIGNALS:
9090
void requestedInitialize();
9191
void requestedShutdown();
92-
void splashFinished();
9392
void windowShown(BitcoinGUI* window);
9493

9594
protected:

src/qt/splashscreen.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,6 @@ bool SplashScreen::eventFilter(QObject * obj, QEvent * ev) {
161161
return QObject::eventFilter(obj, ev);
162162
}
163163

164-
void SplashScreen::finish()
165-
{
166-
/* If the window is minimized, hide() will be ignored. */
167-
/* Make sure we de-minimize the splashscreen window before hiding */
168-
if (isMinimized())
169-
showNormal();
170-
hide();
171-
deleteLater(); // No more need for this
172-
}
173-
174164
static void InitMessage(SplashScreen *splash, const std::string &message)
175165
{
176166
bool invoked = QMetaObject::invokeMethod(splash, "showMessage",

src/qt/splashscreen.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ class SplashScreen : public QWidget
3737
void closeEvent(QCloseEvent *event) override;
3838

3939
public Q_SLOTS:
40-
/** Hide the splash screen window and schedule the splash screen object for deletion */
41-
void finish();
42-
4340
/** Show message and progress */
4441
void showMessage(const QString &message, int alignment, const QColor &color);
4542

0 commit comments

Comments
 (0)