summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 22:56:11 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-02 22:56:11 +0000
commit4b9baf9d5a55852ab9613a04d745e891a6d083f0 (patch)
tree7f1e6043d1b062ea6c69c89a59b78936be7b2503 /base
parente4b6e2966d0128792a461b3ef1c7db1d32dbe279 (diff)
downloadchromium_src-4b9baf9d5a55852ab9613a04d745e891a6d083f0.zip
chromium_src-4b9baf9d5a55852ab9613a04d745e891a6d083f0.tar.gz
chromium_src-4b9baf9d5a55852ab9613a04d745e891a6d083f0.tar.bz2
touch: more fixes in the message pump.
Remove the signal handler when the message-pump terminates. This wouldn't normally be necessary, but it can happen that the message-pump is terminated, and then additional GTK+ operations happen (e.g. in unit_tests). Also check for non-null dispatcher before dispatching events. This can happen for the first-run dialog, and also in the unit_tests. BUG=none TEST=unit_tests Review URL: http://codereview.chromium.org/6596094 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76643 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/message_pump_glib_x.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/base/message_pump_glib_x.cc b/base/message_pump_glib_x.cc
index a0746f4..06a156e 100644
--- a/base/message_pump_glib_x.cc
+++ b/base/message_pump_glib_x.cc
@@ -49,17 +49,27 @@ gboolean GtkWidgetRealizeCallback(GSignalInvocationHint* hint, guint nparams,
// signal for GTK+ widgets, so that whenever the signal triggers for any
// GtkWidget, which means the GtkWidget should now have a GdkWindow, we can
// setup XInput2 events for the GdkWindow.
+static guint realize_signal_id = 0;
+static guint realize_hook_id = 0;
+
void SetupGtkWidgetRealizeNotifier(base::MessagePumpGlibX* msgpump) {
- guint signal_id;
gpointer klass = g_type_class_ref(GTK_TYPE_WIDGET);
- g_signal_parse_name("realize", GTK_TYPE_WIDGET, &signal_id, NULL, FALSE);
- g_signal_add_emission_hook(signal_id, 0, GtkWidgetRealizeCallback,
- static_cast<gpointer>(msgpump), NULL);
+ g_signal_parse_name("realize", GTK_TYPE_WIDGET,
+ &realize_signal_id, NULL, FALSE);
+ realize_hook_id = g_signal_add_emission_hook(realize_signal_id, 0,
+ GtkWidgetRealizeCallback, static_cast<gpointer>(msgpump), NULL);
g_type_class_unref(klass);
}
+void RemoveGtkWidgetRealizeNotifier() {
+ if (realize_signal_id != 0)
+ g_signal_remove_emission_hook(realize_signal_id, realize_hook_id);
+ realize_signal_id = 0;
+ realize_hook_id = 0;
+}
+
#endif // HAVE_XINPUT2
} // namespace
@@ -85,6 +95,9 @@ MessagePumpGlibX::MessagePumpGlibX() : base::MessagePumpForUI(),
}
MessagePumpGlibX::~MessagePumpGlibX() {
+#if defined(HAVE_XINPUT2)
+ RemoveGtkWidgetRealizeNotifier();
+#endif
}
#if defined(HAVE_XINPUT2)
@@ -124,7 +137,7 @@ void MessagePumpGlibX::SetupXInput2ForXWindow(Window xwindow) {
bool MessagePumpGlibX::RunOnce(GMainContext* context, bool block) {
GdkDisplay* gdisp = gdk_display_get_default();
- if (!gdisp)
+ if (!gdisp || !GetDispatcher())
return MessagePumpForUI::RunOnce(context, block);
Display* display = GDK_DISPLAY_XDISPLAY(gdisp);