Skip to content

Commit 7b99ac7

Browse files
john-moffettpsgreco
authored andcommitted
Fixes bitcoin#26490 by preventing notifications
MacOS 13 sends a window focus change notification after the main window has been destroyed but before the QTApplication has been destroyed. This results in the menu bar receiving a notification despite it no longer existing. The solution is to pass the main window as context when subscribing to the notifications. Qt automatically unsubscribes to notifications if the sender OR context is destroyed. Github-Pull: bitcoin-core/gui#680 Rebased-From: 8a5014c (cherry picked from commit 272fa25)
1 parent a12acee commit 7b99ac7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/qt/bitcoingui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ void BitcoinGUI::createMenuBar()
483483
connect(minimize_action, &QAction::triggered, [] {
484484
QApplication::activeWindow()->showMinimized();
485485
});
486-
connect(qApp, &QApplication::focusWindowChanged, [minimize_action] (QWindow* window) {
486+
connect(qApp, &QApplication::focusWindowChanged, this, [minimize_action] (QWindow* window) {
487487
minimize_action->setEnabled(window != nullptr && (window->flags() & Qt::Dialog) != Qt::Dialog && window->windowState() != Qt::WindowMinimized);
488488
});
489489

@@ -498,7 +498,7 @@ void BitcoinGUI::createMenuBar()
498498
}
499499
});
500500

501-
connect(qApp, &QApplication::focusWindowChanged, [zoom_action] (QWindow* window) {
501+
connect(qApp, &QApplication::focusWindowChanged, this, [zoom_action] (QWindow* window) {
502502
zoom_action->setEnabled(window != nullptr);
503503
});
504504
#endif

0 commit comments

Comments
 (0)