[goffice] Fix gnumeric crash when monitoring settings changes. [#644222]



commit 6f9b2b3b8c110af82fd1c6d7db540147ac85cb46
Author: Jean Brefort <jean brefort normalesup org>
Date:   Wed Mar 9 09:45:50 2011 +0100

    Fix gnumeric crash when monitoring settings changes. [#644222]

 ChangeLog                       |    7 +++++++
 NEWS                            |    1 +
 goffice/app/go-conf-gsettings.c |   11 +++++------
 3 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b1a5f16..96cc24f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-09  Jean Brefort  <jean brefort normalesup org>
+
+	reviewed by: <delete if not using a buddy>
+
+	* goffice/app/go-conf-gsettings.c (go_conf_get_node),
+	(cb_key_changed), (go_conf_add_monitor):
+
 2011-03-03  Jean Brefort  <jean brefort normalesup org>
 
 	* configure.in: implement a GSettings backend for GOConf. [643767]
diff --git a/NEWS b/NEWS
index 244910d..68a9f4a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ goffice 0.8.14:
 
 Jean:
 	* Implement a GSettings backend for GOConf. [643767]
+	* Fix gnumeric crash when monitoring settings changes. [#644222]
 
 Morten:
 	* Plug leaks.
diff --git a/goffice/app/go-conf-gsettings.c b/goffice/app/go-conf-gsettings.c
index 02e6f2e..3b23048 100644
--- a/goffice/app/go-conf-gsettings.c
+++ b/goffice/app/go-conf-gsettings.c
@@ -61,14 +61,14 @@ go_conf_get_node (GOConfNode *parent, gchar const *key)
 	char *formatted = go_conf_format_id (key);
 	node = g_new0 (GOConfNode, 1);
 	if (parent) {
-		if (key) {
+		if (key && !parent->key) {
 			node->path = g_strconcat (parent->path, "/", key, NULL);
 			node->id = g_strconcat (parent->id, ".", formatted, NULL);
 		} else {
 			node->path = g_strdup (parent->path);
 			node->id = g_strdup (parent->id);
+			node->key = g_strdup (key? key: parent->key);
 		}
-		node->settings = g_hash_table_lookup (installed_schemas, node->id)? g_settings_new (node->id): NULL;
 	} else {
 		if (key[0] == '/') {
 			node->path = g_strdup (key);
@@ -77,8 +77,8 @@ go_conf_get_node (GOConfNode *parent, gchar const *key)
 			node->path = g_strconcat ("/apps/", key, NULL);
 			node->id = g_strconcat ("org.gnome.", formatted, NULL);
 		}
-		node->settings = g_hash_table_lookup (installed_schemas, node->id)? g_settings_new (node->id): NULL;
 	}
+	node->settings = g_hash_table_lookup (installed_schemas, node->id)? g_settings_new (node->id): NULL;
 	g_free (formatted);
 	if (!node->settings) {
 		char *last_dot = strrchr (node->id, '.');
@@ -514,7 +514,7 @@ cb_key_changed (GSettings *settings,
 		real_key = g_strdup (cls->real_key);
 	} else
 		real_key = g_strconcat (cls->real_key, "/", key, NULL);
-	cls->monitor (cls->node, key , cls->data);
+	cls->monitor (cls->node, real_key , cls->data);
 	g_free (real_key);
 }
 
@@ -532,13 +532,12 @@ go_conf_add_monitor (GOConfNode *node, G_GNUC_UNUSED gchar const *key,
 	cls->monitor = monitor;
 	cls->node = node;
 	cls->data = data;
-	cls->key = g_strdup (key);
+	cls->key = g_strdup (key? key: node->key);
 	cls->real_key = (key)? g_strconcat (node->path, '/', key, NULL): g_strdup (node->path);
 	ret = g_signal_connect
 		(node->settings,
 		 "changed", G_CALLBACK (cb_key_changed),
 		 cls);
-	// FIXME: we need to destroy the closure at some point
 
 	g_hash_table_insert (closures, GUINT_TO_POINTER (ret), cls);
 	return ret;



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