diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 00:57:30 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 00:57:30 +0000 |
commit | 9fe90fe465e046a219411b192d8b08086faae39c (patch) | |
tree | d6bda6eedec768996dd030269e5d4eebb0917766 | |
parent | a92de8fe9754b98c9a9e29bde8dc8def27291487 (diff) | |
download | chromium_src-9fe90fe465e046a219411b192d8b08086faae39c.zip chromium_src-9fe90fe465e046a219411b192d8b08086faae39c.tar.gz chromium_src-9fe90fe465e046a219411b192d8b08086faae39c.tar.bz2 |
GTK: Stop listening to gtk signals in the omnibox before destroying the model.
BUG=123530
TEST=none
Review URL: http://codereview.chromium.org/10103012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132498 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc | 24 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h | 5 |
2 files changed, 20 insertions, 9 deletions
diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc index fcdf76c..82824a2 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc @@ -31,6 +31,7 @@ #include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_screen_util.h" +#include "ui/base/gtk/gtk_signal_registrar.h" #include "ui/base/gtk/gtk_windowing.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/font.h" @@ -276,7 +277,8 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, OmniboxView* omnibox_view, AutocompleteEditModel* edit_model, GtkWidget* location_bar) - : model_(new AutocompletePopupModel(this, edit_model)), + : signal_registrar_(new ui::GtkSignalRegistrar), + model_(new AutocompletePopupModel(this, edit_model)), omnibox_view_(omnibox_view), location_bar_(location_bar), window_(gtk_window_new(GTK_WINDOW_POPUP)), @@ -306,14 +308,14 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - g_signal_connect(window_, "motion-notify-event", - G_CALLBACK(HandleMotionThunk), this); - g_signal_connect(window_, "button-press-event", - G_CALLBACK(HandleButtonPressThunk), this); - g_signal_connect(window_, "button-release-event", - G_CALLBACK(HandleButtonReleaseThunk), this); - g_signal_connect(window_, "expose-event", - G_CALLBACK(HandleExposeThunk), this); + signal_registrar_->Connect(window_, "motion-notify-event", + G_CALLBACK(HandleMotionThunk), this); + signal_registrar_->Connect(window_, "button-press-event", + G_CALLBACK(HandleButtonPressThunk), this); + signal_registrar_->Connect(window_, "button-release-event", + G_CALLBACK(HandleButtonReleaseThunk), this); + signal_registrar_->Connect(window_, "expose-event", + G_CALLBACK(HandleExposeThunk), this); registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, @@ -334,6 +336,10 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, } OmniboxPopupViewGtk::~OmniboxPopupViewGtk() { + // Stop listening to our signals before we destroy the model. I suspect that + // we can race window destruction, otherwise. + signal_registrar_.reset(); + // Explicitly destroy our model here, before we destroy our GTK widgets. // This is because the model destructor can call back into us, and we need // to make sure everything is still valid when it does. diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h index e23b2fc..bd0f8c2 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h +++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.h @@ -32,6 +32,10 @@ namespace gfx { class Image; } +namespace ui { +class GtkSignalRegistrar; +} + class OmniboxPopupViewGtk : public AutocompletePopupView, public content::NotificationObserver { public: @@ -101,6 +105,7 @@ class OmniboxPopupViewGtk : public AutocompletePopupView, CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleExpose, GdkEventExpose*); + scoped_ptr<ui::GtkSignalRegistrar> signal_registrar_; scoped_ptr<AutocompletePopupModel> model_; OmniboxView* omnibox_view_; GtkWidget* location_bar_; |