]> khamidou — GitHub mirrors - electron.git/commitdiff
Remove window from window list before notifying closed event
authorCheng Zhao <zcbenz@gmail.com>
Sat, 27 Jun 2015 09:01:20 +0000 (17:01 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 27 Jun 2015 09:11:36 +0000 (17:11 +0800)
atom/browser/api/atom_api_window.cc
atom/browser/native_window.cc

index 9e8076fe8c91d525a19c8f6851c25c1378f3c9e4..c888676b196069b2949ce83899b564a965bc289e 100644 (file)
@@ -68,8 +68,6 @@ void Window::WillCloseWindow(bool* prevent_default) {
 }
 
 void Window::OnWindowClosed() {
-  Emit("closed");
-
   if (api_web_contents_) {
     api_web_contents_->DestroyWebContents();
     api_web_contents_ = nullptr;
@@ -78,6 +76,8 @@ void Window::OnWindowClosed() {
 
   RemoveFromWeakMap();
   window_->RemoveObserver(this);
+
+  Emit("closed");
 }
 
 void Window::OnWindowBlur() {
index df717c8dec982599feb81e5b5a3b4c233d6d6c9e..b5753c8bca6fe6cb42ac2301a8a7186d2d362e05 100644 (file)
@@ -443,10 +443,10 @@ void NativeWindow::NotifyWindowClosed() {
   if (is_closed_)
     return;
 
+  WindowList::RemoveWindow(this);
+
   is_closed_ = true;
   FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnWindowClosed());
-
-  WindowList::RemoveWindow(this);
 }
 
 void NativeWindow::NotifyWindowBlur() {