[goffice] Enhanced GOString fix.



commit f4d6cd2305beb5a83b4d45bbc4c757277207569b
Author: Jean Brefort <jean brefort normalesup org>
Date:   Fri Aug 5 16:28:45 2011 +0200

    Enhanced GOString fix.

 ChangeLog                 |    7 ++++++-
 goffice/utils/go-string.c |   11 ++++++++---
 2 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0f38522..33a6fbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,7 +5,12 @@
 
 2011-08-05  Jean Brefort  <jean brefort normalesup org>
 
-	* goffice/data/go-data-impl.h: sanitize the get_murkup API.
+	* goffice/utils/go-string.c (replace_rich_base_with_plain): don't loose
+	the ancient base if not destroyed.
+
+2011-08-05  Jean Brefort  <jean brefort normalesup org>
+
+	* goffice/data/go-data-impl.h: sanitize the get_markup API.
 	* goffice/data/go-data.c (_data_scalar_get_markup): ditto.
 	* goffice/data/go-data.h: ditto.
 	* goffice/graph/gog-axis.c (gog_axis_ticks_set_markup),
diff --git a/goffice/utils/go-string.c b/goffice/utils/go-string.c
index 8322f99..2960f4c 100644
--- a/goffice/utils/go-string.c
+++ b/goffice/utils/go-string.c
@@ -83,16 +83,21 @@ replace_rich_base_with_plain (GOStringRichImpl *rich)
 		GSList *shares = g_hash_table_lookup (go_strings_shared, res->base.str);
 		unsigned n = g_slist_length (shares);
 		g_assert (rich->base.ref_count >= n);
-		if (n == 0)
-			res->flags &= ~GO_STRING_IS_SHARED;
 		rich->base.flags &= ~GO_STRING_IS_SHARED;
 		rich->base.ref_count -= n;
+		res->ref_count += n;
 		if (rich->base.ref_count == 0) {
 			rich->base.ref_count = 1;
 			rich->base.base.str = g_strdup (rich->base.base.str); /* don't free the string */
 			go_string_unref ((GOString *) rich);
+		} else {
+			shares = g_slist_prepend (shares, rich);
+			g_hash_table_replace (go_strings_shared,
+			                      (gpointer) res->base.str, shares);
+			n++;
 		}
-		res->ref_count += n;
+		if (n == 0)
+			res->flags &= ~GO_STRING_IS_SHARED;
 	} else
 		g_hash_table_insert (go_strings_shared, (gpointer) res->base.str,
 			g_slist_prepend (NULL, rich));



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