Skip to content

Commit bb48fea

Browse files
Merge #6605: backport: bitcoin-core/gui#605: Delete splash screen widget early
17b40f9 Merge bitcoin-core/gui#605: Delete splash screen widget early (Hennadii Stepanov) Pull request description: ## Issue being fixed or feature implemented Original PR description: > `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. Crash: ``` Thread 0 Crashed:: Dispatch queue: com.apple.main-thread ... 6 libc++abi.dylib 0x19012d6b4 std::terminate() + 108 7 dash-qt 0x1027e5744 SplashScreen::~SplashScreen() + 504 (splashscreen.cpp:142) 8 dash-qt 0x1027e5974 SplashScreen::~SplashScreen() + 4 (splashscreen.cpp:141) [inlined] 9 dash-qt 0x1027e5974 SplashScreen::~SplashScreen() + 36 (splashscreen.cpp:141) ... ``` The issue was introduced via bitcoin#19101 backport (14aa05d) in #6529. ## What was done? Backport bitcoin-core/gui#605 ## How Has This Been Tested? Run `./src/qt/dash-qt --regtest` and press `q` while on splash screen to shutdown asap develop: crash this PR: no crash ## Breaking Changes ## Checklist: - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: knst: utACK 17b40f9 Tree-SHA512: d7f84d66ceaa499fb8f6874c54a389f5e3a852d4b94dc9ae43d9fd0bcf150e8952714d531b6ffb53903f19c1ed11ec5a1d64502a4027672305799d6061ce04e8
2 parents 67b2153 + 17b40f9 commit bb48fea

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
@@ -270,11 +270,7 @@ void BitcoinApplication::createWindow(const NetworkStyle *networkStyle)
270270
void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle)
271271
{
272272
m_splash = new SplashScreen(networkStyle);
273-
// We don't hold a direct pointer to the splash screen after creation, but the splash
274-
// screen will take care of deleting itself when finish() happens.
275273
m_splash->show();
276-
connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish);
277-
connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);
278274
}
279275

280276
void BitcoinApplication::createNode(interfaces::Init& init)
@@ -332,6 +328,9 @@ void BitcoinApplication::requestShutdown()
332328
w->hide();
333329
}
334330

331+
delete m_splash;
332+
m_splash = nullptr;
333+
335334
// Show a simple window indicating shutdown status
336335
// Do this first as some of the steps may take some time below,
337336
// for example the RPC console may still be executing a command.
@@ -371,10 +370,13 @@ void BitcoinApplication::requestShutdown()
371370
void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
372371
{
373372
qDebug() << __func__ << ": Initialization result: " << success;
373+
374374
// Set exit result.
375375
returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
376-
if(success)
377-
{
376+
if(success) {
377+
delete m_splash;
378+
m_splash = nullptr;
379+
378380
// Log this only after AppInitMain finishes, as then logging setup is guaranteed complete
379381
qInfo() << "Platform customization:" << gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM).c_str();
380382
clientModel = new ClientModel(node(), optionsModel);
@@ -397,7 +399,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
397399
} else {
398400
window->showMinimized();
399401
}
400-
Q_EMIT splashFinished();
401402
Q_EMIT windowShown(window);
402403

403404
// Let the users setup their preferred appearance if there are no settings for it defined yet.
@@ -417,7 +418,6 @@ void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHead
417418
#endif
418419
pollShutdownTimer->start(SHUTDOWN_POLLING_DELAY);
419420
} else {
420-
Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown
421421
requestShutdown();
422422
}
423423
}

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)