#52598: fix: use WeakPtr for MenuDelegate cancellation
Merged
Description of Change
Resolves #52579
MenuDelegate cancellation used base::Unretained and didn't guarantee the callee lifecycle. This change adds WeakPtrFactory to MenuDelegate so cancel-on-destroy semantics protect the cancellation callback if the MenuDelegate is destroyed before the event loop runs the callback.
This issue was actually originally reported by Microsoft 8 years ago in #14213
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed a crash when quickly switching menus while the app is under heavy load.
Backports
Semver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron