diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 10:45:13 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 10:45:13 +0000 |
commit | fa40033d085aff31f7382b3b9c95f2e8c3e9a1b0 (patch) | |
tree | 9d594573bad50c3dcb15e54f0ffa41fd4e975964 | |
parent | 1cc43f048e28a16271f9c4a10446c04a38f60496 (diff) | |
download | chromium_src-fa40033d085aff31f7382b3b9c95f2e8c3e9a1b0.zip chromium_src-fa40033d085aff31f7382b3b9c95f2e8c3e9a1b0.tar.gz chromium_src-fa40033d085aff31f7382b3b9c95f2e8c3e9a1b0.tar.bz2 |
Removing DeleteSoon() from WigetGtk so it behaves like WidgetWin
This is a retry of http://codereview.chromium.org/7002029/ after it has been reverted because of the failing test BrowserTest.CloseWithAppMenuOpen (failed only on buildbot)
BUG=chromium-os:15129
TEST=tests
TBR=dpolukhin
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85257 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | views/widget/widget_gtk.cc | 21 | ||||
-rw-r--r-- | views/widget/widget_gtk.h | 4 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 3 | ||||
-rw-r--r-- | views/window/window_gtk.h | 1 |
4 files changed, 20 insertions, 9 deletions
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index b506dac..6fe0248 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -322,6 +322,9 @@ WidgetGtk::WidgetGtk() } WidgetGtk::~WidgetGtk() { + LOG(ERROR) << this << " WidgetGtk::~WidgetGtk()"; // FIXME + if (!delete_on_destroy_ && widget_) + CloseNow(); // We need to delete the input method before calling DestroyRootView(), // because it'll set focus_manager_ to NULL. input_method_.reset(); @@ -900,15 +903,16 @@ void WidgetGtk::MoveAbove(gfx::NativeView native_view) { } void WidgetGtk::SetShape(gfx::NativeRegion region) { - DCHECK(widget_); - DCHECK(widget_->window); - gdk_window_shape_combine_region(widget_->window, region, 0, 0); - gdk_region_destroy(region); + if (widget_ && widget_->window) { + gdk_window_shape_combine_region(widget_->window, region, 0, 0); + gdk_region_destroy(region); + } } void WidgetGtk::Close() { if (!widget_) return; // No need to do anything. + LOG(ERROR) << this << " WidgetGtk::Close()"; // FIXME // Hide first. Hide(); @@ -1304,17 +1308,16 @@ void WidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) { } void WidgetGtk::OnDestroy(GtkWidget* object) { + LOG(ERROR) << this << " WidgetGtk::OnDestroy" << delete_on_destroy_; // FIXME if (!child_) ActiveWindowWatcherX::RemoveObserver(this); // Note that this handler is hooked to GtkObject::destroy. // NULL out pointers here since we might still be in an observerer list // until delstion happens. widget_ = window_contents_ = NULL; - if (delete_on_destroy_) { - // Delays the deletion of this WidgetGtk as we want its children to have - // access to it when destroyed. - MessageLoop::current()->DeleteSoon(FROM_HERE, this); - } + OnDestroyed(); + if (delete_on_destroy_) + delete this; } void WidgetGtk::OnShow(GtkWidget* widget) { diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index eaa29cd..d60a82f 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -253,6 +253,10 @@ class WidgetGtk : public Widget, CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnMap); CHROMEGTK_CALLBACK_0(WidgetGtk, void, OnHide); + // Invoked when the widget is destroyed and right before the object + // destruction. Useful for overriding. + virtual void OnDestroyed() { } + // Invoked when gtk grab is stolen by other GtkWidget in the same // application. virtual void HandleGtkGrabBroke(); diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 0e7a6f2..d55d657 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -443,6 +443,9 @@ void WindowGtk::SaveWindowPosition() { void WindowGtk::OnDestroy(GtkWidget* widget) { delegate_->OnNativeWindowDestroying(); WidgetGtk::OnDestroy(widget); +} + +void WindowGtk::OnDestroyed() { delegate_->OnNativeWindowDestroyed(); } diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index e659e4a..72782a5 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -91,6 +91,7 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window { friend class Window; virtual void OnDestroy(GtkWidget* widget); + virtual void OnDestroyed(); private: static gboolean CallConfigureEvent(GtkWidget* widget, |