]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Clears the delegate when window is going to be closed
authorCheng Zhao <zcbenz@gmail.com>
Thu, 26 Nov 2015 05:55:59 +0000 (13:55 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 26 Nov 2015 06:11:17 +0000 (14:11 +0800)
Since EL Capitan it is possible that the methods of delegate would get
called after the window has been closed.

Refs atom/atom#9584.

atom/browser/native_window_mac.mm

index 28c8a5ae59a0814ec8a05f9294ab32d222ab7273..a9ac0cb5de79411eff916cee47590610bf7cd767 100644 (file)
@@ -192,6 +192,11 @@ bool ScopedDisableResize::disable_resize_ = false;
 
 - (void)windowWillClose:(NSNotification*)notification {
   shell_->NotifyWindowClosed();
+
+  // Clears the delegate when window is going to be closed, since EL Capitan it
+  // is possible that the methods of delegate would get called after the window
+  // has been closed.
+  [shell_->GetNativeWindow() setDelegate:nil];
 }
 
 - (BOOL)windowShouldClose:(id)window {