Blob Blame History Raw
From 9f5bbc676cbf712c42a3ad0554cc832c28380981 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Fri, 5 Sep 2014 12:49:41 +0200
Subject: [PATCH 2/2] keyboard: Fix a crash if the WM changes (or restarts)

By stopping watching for WM changes when leaving the shortcuts panel.

 #0 reload_sections
 #1 wm_window_event_filter
 #2 gdk_event_apply_filters at gdkeventsource.c:81
 #3 gdk_event_source_translate_event at gdkeventsource.c:195
 #4 _gdk_x11_display_queue_events at gdkeventsource.c:338
 #5 gdk_display_get_event at gdkdisplay.c:313
 #10 g_main_context_iteration at gmain.c:3766
 #11 g_application_run at gapplication.c:1623

See https://bugzilla.redhat.com/show_bug.cgi?id=1094480

https://bugzilla.gnome.org/show_bug.cgi?id=736117

Conflicts:
	panels/keyboard/keyboard-shortcuts.c
---
 panels/keyboard/keyboard-shortcuts.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index 0dd7539..3b05fdd 100644
--- a/panels/keyboard/keyboard-shortcuts.c
+++ b/panels/keyboard/keyboard-shortcuts.c
@@ -87,6 +87,7 @@ static GtkWidget *custom_shortcut_command_entry = NULL;
 static GHashTable *kb_system_sections = NULL;
 static GHashTable *kb_apps_sections = NULL;
 static GHashTable *kb_user_sections = NULL;
+static gpointer wm_changed_id = NULL;
 
 static void
 free_key_array (GPtrArray *keys)
@@ -1844,8 +1845,8 @@ void
 keyboard_shortcuts_init (CcPanel *panel, GtkBuilder *builder)
 {
   g_object_set_data (G_OBJECT (panel), "builder", builder);
-  wm_common_register_window_manager_change ((GFunc) on_window_manager_change,
-                                            panel);
+  wm_changed_id = wm_common_register_window_manager_change ((GFunc) on_window_manager_change,
+                                                            panel);
   pictures_regex = g_regex_new ("\\$PICTURES", 0, 0, NULL);
   setup_dialog (panel, builder);
   reload_sections (panel);
@@ -1927,5 +1928,11 @@ keyboard_shortcuts_dispose (CcPanel *panel)
 
   g_clear_object (&binding_settings);
 
+  if (wm_changed_id)
+    {
+      wm_common_unregister_window_manager_change (wm_changed_id);
+      wm_changed_id = NULL;
+    }
+
   cc_keyboard_option_clear_all ();
 }
-- 
2.1.0