diff --git a/atom/browser/native_window_gtk.cc b/atom/browser/native_window_gtk.cc index f50fad7c74b..1000af2809e 100644 --- a/atom/browser/native_window_gtk.cc +++ b/atom/browser/native_window_gtk.cc @@ -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; }