This is a PR to address https://github.com/bitcoin/bitcoin/issues/26490
The menu bar currently subscribes to window focus change notifications to enable or disable certain menu options in response to the window status.
Notifications are automatically unsubscribed (disconnected in Qt parlance) if the sender is deleted – in this case, the sender is the QTApplication object (qApp
). However, MacOS 13 sends a window focus change notification after the main window has been destroyed but before qApp
has been fully destroyed.
Since the menu bar is deleted in the main window’s destructor, it no longer exists when it receives these notifications (in two different places via lambda expressions). The solution is to pass the main window (this
) as context when subscribing to the notifications. In this overloaded version of connect
, Qt automatically unsubscribes to notifications if the sender OR context (here the main window object) is destroyed. Since the spurious notifications are sent after the main window object is destroyed, this change prevents them from being sent.
Tested on Mac OS 13 and 12 only.