#49648: fix: remove menu observer before destroying menu_controller_
Merged
Description of Change
Follow up to #48351
A previous refactor uncovered a long-standing bug in MenuMac::~MenuMac() 's lifetime cycle: When MenuMac::~MenuMac() was being destroyed by GC, during implicit destruction of menu_controller_, it could trigger callbacks to the model through observer notifications. Menu::~Menu() ran after, removing the observer too late.
This PR moves the observer cleanup from Menu::~Menu() to MenuMac::~MenuMac(), removing the observer before menu_controller_ is destroyed and preventing callbacks during the deallocation.
Checklist
- PR description included
- I have built and tested this PR
-
npm testpasses - tests are changed or added
- relevant API documentation, tutorials, and examples are updated and follow the documentation style guide
- PR release notes describe the change in a way relevant to app developers, and are capitalized, punctuated, and past tense.
Release Notes
Notes: Fixed an application crash on MacOS where the menu observer was not being properly removed before garbage collection.
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