Skip to content

Commit

Permalink
fix: potential crash on macOS app exit (#29941)
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere authored and Milan Burda committed Jul 14, 2021
1 parent e48e899 commit 250c398
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 250c398

Please sign in to comment.