#52520: refactor: rework PowerMonitor 'shutdown' event on macOS to avoid UB
Merged
Description of Change
Pulled out of #52418, as it was identified by the UBSan build. This is a latent bug that hasn't bit us yet because while Browser::SetShutdownHandler is called after Browser is deleted, the this pointer is never used in that function body.
In many ways Browser::SetShutdownHandler is a vestigial leftover from past code, so refactoring this to more cleanly separate concerns here.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses - tests are changed or added
Release Notes
Notes: none
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