Index: chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc |
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 fcdf76c9dd06337f54da10afc1991c30f92c9b55..82824a2dec1b6ce1193531d402d1454e87141188 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. |