Commit 9fe90fe4 authored by erg@chromium.org's avatar erg@chromium.org

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
parent a92de8fe
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_compat.h"
#include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_hig_constants.h"
#include "ui/base/gtk/gtk_screen_util.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/base/gtk/gtk_windowing.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/gfx/font.h" #include "ui/gfx/font.h"
...@@ -276,7 +277,8 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, ...@@ -276,7 +277,8 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font,
OmniboxView* omnibox_view, OmniboxView* omnibox_view,
AutocompleteEditModel* edit_model, AutocompleteEditModel* edit_model,
GtkWidget* location_bar) GtkWidget* location_bar)
: model_(new AutocompletePopupModel(this, edit_model)), : signal_registrar_(new ui::GtkSignalRegistrar),
model_(new AutocompletePopupModel(this, edit_model)),
omnibox_view_(omnibox_view), omnibox_view_(omnibox_view),
location_bar_(location_bar), location_bar_(location_bar),
window_(gtk_window_new(GTK_WINDOW_POPUP)), window_(gtk_window_new(GTK_WINDOW_POPUP)),
...@@ -306,14 +308,14 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, ...@@ -306,14 +308,14 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font,
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK); GDK_BUTTON_RELEASE_MASK);
g_signal_connect(window_, "motion-notify-event", signal_registrar_->Connect(window_, "motion-notify-event",
G_CALLBACK(HandleMotionThunk), this); G_CALLBACK(HandleMotionThunk), this);
g_signal_connect(window_, "button-press-event", signal_registrar_->Connect(window_, "button-press-event",
G_CALLBACK(HandleButtonPressThunk), this); G_CALLBACK(HandleButtonPressThunk), this);
g_signal_connect(window_, "button-release-event", signal_registrar_->Connect(window_, "button-release-event",
G_CALLBACK(HandleButtonReleaseThunk), this); G_CALLBACK(HandleButtonReleaseThunk), this);
g_signal_connect(window_, "expose-event", signal_registrar_->Connect(window_, "expose-event",
G_CALLBACK(HandleExposeThunk), this); G_CALLBACK(HandleExposeThunk), this);
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_BROWSER_THEME_CHANGED, chrome::NOTIFICATION_BROWSER_THEME_CHANGED,
...@@ -334,6 +336,10 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font, ...@@ -334,6 +336,10 @@ OmniboxPopupViewGtk::OmniboxPopupViewGtk(const gfx::Font& font,
} }
OmniboxPopupViewGtk::~OmniboxPopupViewGtk() { 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. // 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 // This is because the model destructor can call back into us, and we need
// to make sure everything is still valid when it does. // to make sure everything is still valid when it does.
......
...@@ -32,6 +32,10 @@ namespace gfx { ...@@ -32,6 +32,10 @@ namespace gfx {
class Image; class Image;
} }
namespace ui {
class GtkSignalRegistrar;
}
class OmniboxPopupViewGtk : public AutocompletePopupView, class OmniboxPopupViewGtk : public AutocompletePopupView,
public content::NotificationObserver { public content::NotificationObserver {
public: public:
...@@ -101,6 +105,7 @@ class OmniboxPopupViewGtk : public AutocompletePopupView, ...@@ -101,6 +105,7 @@ class OmniboxPopupViewGtk : public AutocompletePopupView,
CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleExpose, CHROMEGTK_CALLBACK_1(OmniboxPopupViewGtk, gboolean, HandleExpose,
GdkEventExpose*); GdkEventExpose*);
scoped_ptr<ui::GtkSignalRegistrar> signal_registrar_;
scoped_ptr<AutocompletePopupModel> model_; scoped_ptr<AutocompletePopupModel> model_;
OmniboxView* omnibox_view_; OmniboxView* omnibox_view_;
GtkWidget* location_bar_; GtkWidget* location_bar_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment