diff options
Diffstat (limited to 'views/widget/widget_gtk.cc')
-rw-r--r-- | views/widget/widget_gtk.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 8762e14..64a9063 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -106,9 +106,10 @@ WidgetGtk::WidgetGtk(Type type) } WidgetGtk::~WidgetGtk() { - if (type_ != TYPE_CHILD) - ActiveWindowWatcherX::RemoveObserver(this); - MessageLoopForUI::current()->RemoveObserver(this); + // If we're deleted directly, instead of via OnDestroy(), then clean up after + // ourselves. + delete_on_destroy_ = false; // Prevent double free. + CloseNow(); } GtkWindow* WidgetGtk::GetTransientParent() const { @@ -818,6 +819,9 @@ void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { void WidgetGtk::OnDestroy() { widget_ = window_contents_ = NULL; + if (type_ != TYPE_CHILD) + ActiveWindowWatcherX::RemoveObserver(this); + MessageLoopForUI::current()->RemoveObserver(this); if (delete_on_destroy_) { // Delays the deletion of this WidgetGtk as we want its children to have // access to it when destroyed. |