[gnome-control-center] keyboard: Fix crasher when num workspace changes



commit 6c6c37609c609db9f74220ff6c453cc1457287ca
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Mar 16 12:49:03 2011 +0000

    keyboard: Fix crasher when num workspace changes
    
    And the panel has already been closed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=644784
    https://bugzilla.redhat.com/show_bug.cgi?id=684368

 panels/keyboard/keyboard-shortcuts.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/panels/keyboard/keyboard-shortcuts.c b/panels/keyboard/keyboard-shortcuts.c
index c043b1e..a1ea072 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 guint workspace_num_notify_id = 0;
 
 static void
 free_key_array (GPtrArray *keys)
@@ -1794,10 +1795,10 @@ setup_dialog (CcPanel *panel, GtkBuilder *builder)
 
   gconf_client_add_dir (client, GCONF_BINDING_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
   gconf_client_add_dir (client, "/apps/metacity/general", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
-  gconf_client_notify_add (client,
-                           "/apps/metacity/general/num_workspaces",
-                           (GConfClientNotifyFunc) key_entry_controlling_key_changed,
-                           builder, NULL, NULL);
+  workspace_num_notify_id = gconf_client_notify_add (client,
+                                                     "/apps/metacity/general/num_workspaces",
+                                                     (GConfClientNotifyFunc) key_entry_controlling_key_changed,
+                                                     builder, NULL, NULL);
 
   model = gtk_list_store_new (DETAIL_N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER);
   gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (model),
@@ -1919,5 +1920,13 @@ keyboard_shortcuts_dispose (CcPanel *panel)
           g_hash_table_destroy (kb_user_sections);
           kb_user_sections = NULL;
         }
+      if (workspace_num_notify_id != 0)
+        {
+          GConfClient *client;
+          client = gconf_client_get_default ();
+          gconf_client_notify_remove (client, workspace_num_notify_id);
+          workspace_num_notify_id = 0;
+          g_object_unref (client);
+        }
     }
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]