Skip to content

fix: weakly reference MenuModel from MenuController - #23778

Merged
codebytere merged 1 commit into
masterfrom
menu-model-mac-weak
May 27, 2020
Merged

codebytere merged 1 commit into
masterfrom
menu-model-mac-weak

Conversation

@codebytere

@codebytere codebytere commented May 26, 2020 •

Copy link
Copy Markdown
Member

Description of Change

Refs:

Fixes a crash i've seen intermittently in Sentry on Catalina machines running Fiddle.

From the OG CL:

Before this CL, MenuController's contract required that the provided MenuModel outlived a MenuController instance. As of 10.15, it's impossible to fulfill that contract: AppKit seems to like keeping MenuController instances (via [NSMenuItem target]) alive until the next autorelease pool drain, and there's no way for the C++ code that creates & manages a MenuModel to know when that will happen.

This PR makes it such that ElectronMenuController holds a base::WeakPtr to its ElectronMenuModel, rather than a raw ptr, and handles the ElectronMenuModel being destroyed before the ElectronMenuController.

cc @MarshallOfSound @zcbenz

Checklist

Release Notes

Notes: Fixed an occasional menu crash on macOS Catalina when menu is closing.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 26, 2020
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label May 27, 2020
@codebytere
codebytere merged commit 7b0a844 into master May 27, 2020
@release-clerk

release-clerk Bot commented May 27, 2020

Copy link
Copy Markdown

Release Notes Persisted

Fixed an occasional menu crash on macOS Catalina when menu is closing.

@trop

trop Bot commented May 27, 2020

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "10-x-y", please check out #23806

@trop trop Bot removed the target/10-x-y label May 27, 2020
@trop

trop Bot commented May 27, 2020

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "8-x-y", please check out #23807

@trop

trop Bot commented May 27, 2020

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "9-x-y", please check out #23808

@trop trop Bot added the merged/9-x-y label May 28, 2020
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