Skip to content

Commit 17b40f9

Browse files
hebastoUdjinM6
authored andcommitted
Merge bitcoin-core/gui#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 bitcoin-core/gui#604. Fixes bitcoin#25146. Fixes 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](bitcoin-core/gui#604 (comment)) follows. ACKs for top commit: dooglus: ACK bitcoin-core/gui@1b22849 furszy: ACK 1b22849 john-moffett: ACK 1b22849 Tree-SHA512: bb01d0bf2051f5b184dc415c4f5d32dfb7b8bd772feff7ec7754ded4c6482de27f004b9712df7d53c5ee82e153f48aef4372e4a49d7bcbbb137f73e9b4947962
1 parent 26ea618 commit 17b40f9

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
@@ -266,11 +266,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
266266
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
267267
{
268268
m_splash = new SplashScreen(networkStyle);
269-
// We don't hold a direct pointer to the splash screen after creation, but the splash
270-
// screen will take care of deleting itself when finish() happens.
271269
m_splash->show();
272-
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
273-
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
274270
}
275271

276272
void BitcoinApplication::createNode(interfaces::Init& init)
@@ -328,6 +324,9 @@ void BitcoinApplication::requestShutdown()
328324
w->hide();
329325
}
330326

327+
delete m_splash;
328+
m_splash = nullptr;
329+
331330
// Show a simple window indicating shutdown status
332331
// Do this first as some of the steps may take some time below,
333332
// for example the RPC console may still be executing a command.
@@ -367,10 +366,13 @@ void BitcoinApplication::requestShutdown()
367366
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
368367
{
369368
qDebug() << __func__ << ": Initialization result: " << success;
369+
370370
// Set exit result.
371371
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
372-
if(success)
373-
{
372+
if(success) {
373+
delete m_splash;
374+
m_splash = nullptr;
375+
374376
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
375377
qInfo() << "Platform customization:" << gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM).c_str();
376378
clientModel = new ClientModel(node(), optionsModel);
@@ -393,7 +395,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
393395
} else {
394396
window->showMinimized();
395397
}
396-
Q_EMIT splashFinished();
397398
Q_EMIT windowShown(window);
398399

399400
// Let the users setup their preferred appearance if there are no settings for it defined yet.
@@ -413,7 +414,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
413414
#endif
414415
pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY);
415416
} else {
416-
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
417417
requestShutdown();
418418
}
419419
}

src/qt/bitcoin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public Q_SLOTS:
8686
void requestedInitialize();
8787
void requestedRestart(QStringList args);
8888
void requestedShutdown();
89-
void splashFinished();
9089
void windowShown(BitcoinGUI* window);
9190

9291
protected:

src/qt/splashscreen.cpp

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

169-
void SplashScreen::finish()
170-
{
171-
/* If the window is minimized, hide() will be ignored. */
172-
/* Make sure we de-minimize the splashscreen window before hiding */
173-
if (isMinimized())
174-
showNormal();
175-
hide();
176-
deleteLater(); // No more need for this
177-
}
178-
179169
static void InitMessage(SplashScreen *splash, const std::string &message)
180170
{
181171
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)