Skip to content

Commit 00f8492

Browse files
committed
Merge bitcoin-core#547: Override BitcoinApplication::event() to handle QEvent::Quit
e7fc506 qt: Override BitcoinApplication::event() to handle QEvent::Quit (Hennadii Stepanov) Pull request description: bitcoin-core#336 introduced a regression when termination requests from a platform are not handled properly. This PR fixes this regression. On macOS shutdown after clicking "Quit" in Dock icon menu, and during logout works again. Fixes bitcoin-core#545. ACKs for top commit: RandyMcMillan: tACK e7fc506 Sjors: tACK e7fc506 (rebased on master) indeed fixes the crash described in bitcoin-core#545 promag: Tested ACK e7fc506 on macOS 10.15 with Qt 5.15.2. Tree-SHA512: 236a483dc0828f22999469e133b8ac9f0b6267ec2a27004c3ebaa967689ddb972ea1fa90c1dd41f3bff3d17bf571a707babcef53bd79fd711fda98cfbf120131
2 parents 48a90c6 + e7fc506 commit 00f8492

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/qt/bitcoin.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,16 @@ WId BitcoinApplication::getMainWinId() const
454454
return window->winId();
455455
}
456456

457+
bool BitcoinApplication::event(QEvent* e)
458+
{
459+
if (e->type() == QEvent::Quit) {
460+
requestShutdown();
461+
return true;
462+
}
463+
464+
return QApplication::event(e);
465+
}
466+
457467
static void SetupUIArgs(ArgsManager& argsman)
458468
{
459469
argsman.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), ArgsManager::ALLOW_ANY, OptionsCategory::GUI);

src/qt/bitcoin.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ public Q_SLOTS:
9292
void splashFinished();
9393
void windowShown(BitcoinGUI* window);
9494

95+
protected:
96+
bool event(QEvent* e) override;
97+
9598
private:
9699
std::optional<InitExecutor> m_executor;
97100
OptionsModel *optionsModel;

0 commit comments

Comments
 (0)