gtk: Free resources when closing window.
authorCheng Zhao <zcbenz@gmail.com>
Wed, 23 Apr 2014 04:59:03 +0000 (12:59 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 23 Apr 2014 04:59:03 +0000 (12:59 +0800)
atom/browser/native_window_gtk.cc

index f50fad7..1000af2 100644 (file)
@@ -121,10 +121,7 @@ NativeWindowGtk::NativeWindowGtk(content::WebContents* web_contents,
 }
 
 NativeWindowGtk::~NativeWindowGtk() {
-  ui::ActiveWindowWatcherX::RemoveObserver(this);
-
-  if (window_)
-    gtk_widget_destroy(GTK_WIDGET(window_));
+  CloseImmediately();
 }
 
 void NativeWindowGtk::Close() {
@@ -132,7 +129,12 @@ void NativeWindowGtk::Close() {
 }
 
 void NativeWindowGtk::CloseImmediately() {
+  if (window_ == NULL)
+    return;
+
   NotifyWindowClosed();
+  ui::ActiveWindowWatcherX::RemoveObserver(this);
+
   gtk_widget_destroy(GTK_WIDGET(window_));
   window_ = NULL;
 }