Skip to content

fix: resolve crash on close bug in macos#5162

Merged
UdjinM6 merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix-crash-shutdown
Jan 22, 2023
Merged

fix: resolve crash on close bug in macos#5162
UdjinM6 merged 1 commit into
dashpay:developfrom
PastaPastaPasta:fix-crash-shutdown

Conversation

@PastaPastaPasta
Copy link
Copy Markdown
Member

@PastaPastaPasta PastaPastaPasta commented Jan 14, 2023

Issue being fixed or feature implemented

Fixes two crash on close bugs on macOS. I thought there were some GitHub issues that describe them, but I can't find them now.

This should be merged via merge commit to preserve the fact this is a backport

What was done?

zoom_action and minimize_action are both actions inside of window_menu and window_menu is inside of appMenuBar. appMenuBar is deleted on quit, which also deletes all the stuff inside of it, and invalidates the pointers we are holding onto inside of these lambdas. I had a different fix that was from capturing this inside of the lambda, and checking if appMenuBar was deleted yet, however bitcoin actually dealt with this fix in bitcoin-core/gui#680

This should get back ported if we create another 18.2 / 18.1 version

How Has This Been Tested?

starting and stopping many times

Breaking Changes

None

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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

UdjinM6
UdjinM6 previously approved these changes Jan 16, 2023
Copy link
Copy Markdown

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@PastaPastaPasta PastaPastaPasta changed the title fix: resolve two crash on close bugs in macos fix: resolve crash on close bug in macos Jan 18, 2023
…tain notifications after main window is destroyed

8a5014c Fixes bitcoin#26490 by preventing notifications (John Moffett)

Pull request description:

  This is a PR to address bitcoin#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](https://doc.qt.io/qt-5/qobject.html#connect-1) 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.

ACKs for top commit:
  hebasto:
    ACK 8a5014c

Tree-SHA512: 3dff0a252fe0e93dd68cf5503135ecf6a72bcf385ba38407d6021ab77cca323f8bbe58aeca90ec124aa2a22ab9d35b706946179ac3b5d171c96a7010de51a090
@UdjinM6 UdjinM6 force-pushed the fix-crash-shutdown branch from 1fa890d to 512503c Compare January 22, 2023 20:57
@UdjinM6 UdjinM6 merged commit 74b273f into dashpay:develop Jan 22, 2023
@PastaPastaPasta PastaPastaPasta deleted the fix-crash-shutdown branch January 22, 2023 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants