Skip to content

Commit

Permalink
fix: potential crash on macOS app exit (#29941) (#30138)
Browse files Browse the repository at this point in the history
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
miniak and codebytere committed Jul 15, 2021
1 parent 705a9a3 commit 488fbfe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shell/browser/native_window_mac.mm
Expand Up @@ -498,7 +498,7 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
// Use an NSEvent monitor to listen for the wheel event.
BOOL __block began = NO;
wheel_event_monitor_ = [NSEvent
addLocalMonitorForEventsMatchingMask:NSScrollWheelMask
addLocalMonitorForEventsMatchingMask:NSEventMaskScrollWheel
handler:^(NSEvent* event) {
if ([[event window] windowNumber] !=
[window_ windowNumber])
Expand Down Expand Up @@ -539,7 +539,10 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
DCHECK(!IsClosed());
ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this);
display::Screen::GetScreen()->RemoveObserver(this);
[NSEvent removeMonitor:wheel_event_monitor_];
if (wheel_event_monitor_) {
[NSEvent removeMonitor:wheel_event_monitor_];
wheel_event_monitor_ = nil;
}
}

void NativeWindowMac::RedrawTrafficLights() {
Expand Down

0 comments on commit 488fbfe

Please sign in to comment.