Skip to content

Commit

Permalink
fix: potential crash on macOS app exit (#29962)
Browse files Browse the repository at this point in the history
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Jul 1, 2021
1 parent 9957887 commit ebd1261
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions shell/browser/native_window_mac.mm
Expand Up @@ -415,7 +415,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 @@ -1699,7 +1699,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::OverrideNSWindowContentView() {
Expand Down

0 comments on commit ebd1261

Please sign in to comment.