Skip to content

Commit

Permalink
fix: remove event monitor before destroying window
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Nov 27, 2018
1 parent 9ff7807 commit d1f0d6c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion atom/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

NativeWindowMac::~NativeWindowMac() {
[NSEvent removeMonitor:wheel_event_monitor_];
if (wheel_event_monitor_)
[NSEvent removeMonitor:wheel_event_monitor_];
}

void NativeWindowMac::SetContentView(views::View* view) {
Expand Down Expand Up @@ -517,6 +518,13 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

void NativeWindowMac::CloseImmediately() {
// Remove event monitor before destroying window, otherwise the monitor may
// call its callback after window has been destroyed.
if (wheel_event_monitor_) {
[NSEvent removeMonitor:wheel_event_monitor_];
wheel_event_monitor_ = nil;
}

// Retain the child window before closing it. If the last reference to the
// NSWindow goes away inside -[NSWindow close], then bad stuff can happen.
// See e.g. http://crbug.com/616701.
Expand Down

0 comments on commit d1f0d6c

Please sign in to comment.