[Gnucash-changes] r12140 - gnucash/trunk - Don't misuse the Quark storage for pointers, especially because they're not integer-sized on a 64-bit platform.

Joshua Sled jsled at cvs.gnucash.org
Tue Dec 6 20:34:45 EST 2005


Author: jsled
Date: 2005-12-06 20:34:44 -0500 (Tue, 06 Dec 2005)
New Revision: 12140
Trac: http://svn.gnucash.org/trac/changeset/12140

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h
   gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph.c
Log:
Don't misuse the Quark storage for pointers, especially because they're not integer-sized on a 64-bit platform.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2005-12-06 22:06:22 UTC (rev 12139)
+++ gnucash/trunk/ChangeLog	2005-12-07 01:34:44 UTC (rev 12140)
@@ -1,3 +1,10 @@
+2005-12-06  Joshua Sled  <jsled at asynchronous.org>
+
+	* gog-graph-impl.h: 
+	* gog-graph.c (gog_graph_unref_data), (gog_graph_ref_data): Don't
+	misuse the Quark storage for pointers, especially because they're
+	not integer-sized on a 64-bit platform.
+
 2005-12-06  Derek Atkins  <derek at ihtfp.com>
 
 	* configure.in: remove libgsf/po/Makefile and goffice/po/Makefile

Modified: gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h
===================================================================
--- gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h	2005-12-06 22:06:22 UTC (rev 12139)
+++ gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h	2005-12-07 01:34:44 UTC (rev 12140)
@@ -35,6 +35,7 @@
 	GogTheme *theme;
 	GSList	 *charts;
 	GSList	 *data;
+	GHashTable *ref_counts;
 
 	unsigned  num_cols, num_rows;
 	double	  width, height;

Modified: gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph.c
===================================================================
--- gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph.c	2005-12-06 22:06:22 UTC (rev 12139)
+++ gnucash/trunk/lib/goffice-0.0.4/goffice/graph/gog-graph.c	2005-12-07 01:34:44 UTC (rev 12140)
@@ -118,6 +118,11 @@
 	g_slist_foreach (tmp, (GFunc) g_object_unref, NULL);
 	g_slist_free (tmp);
 
+	if (graph->ref_counts != NULL) {
+		g_hash_table_destroy(graph->ref_counts);
+		graph->ref_counts = NULL;
+	}
+
 	/* on exit the role remove routines are not called */
 	g_slist_free (graph->charts);
 
@@ -238,6 +243,7 @@
 
 	graph->data = NULL;
 	graph->num_cols = graph->num_rows = 0;
+	graph->ref_counts = g_hash_table_new(NULL, NULL);
 	graph->width = GOG_GRAPH_DEFAULT_WIDTH;
 	graph->height = GOG_GRAPH_DEFAULT_HEIGHT;
 	graph->idle_handler = 0;
@@ -411,7 +417,8 @@
 
 	/* Does it already exist in the graph ? */
 	g_obj = G_OBJECT (graph);
-	res = g_object_get_qdata (g_obj, (GQuark)dat);
+	//res = g_object_get_qdata (g_obj, (GQuark)dat);
+	res = g_hash_table_lookup(GOG_GRAPH(graph)->ref_counts, dat);
 	if (res == NULL) {
 
 		/* is there something like it already */
@@ -426,12 +433,14 @@
 			g_object_ref (dat);
 		} else {
 			dat = existing->data;
-			res = g_object_get_qdata (g_obj, (GQuark)dat);
+			//res = g_object_get_qdata (g_obj, (GQuark)dat);
+			res = g_hash_table_lookup(GOG_GRAPH(graph)->ref_counts, dat);
 		}
 	}
 
 	count = GPOINTER_TO_UINT (res) + 1;
-	g_object_set_qdata (g_obj, (GQuark)dat, GUINT_TO_POINTER (count));
+	//g_object_set_qdata (g_obj, (GQuark)dat, GUINT_TO_POINTER (count));
+	g_hash_table_insert(GOG_GRAPH(graph)->ref_counts, dat, GUINT_TO_POINTER (count));
 	g_object_ref (dat);
 	return dat;
 }
@@ -466,7 +475,8 @@
 		return;
 
 	g_obj = G_OBJECT (graph);
-	res = g_object_get_qdata (g_obj, (GQuark)dat);
+	//res = g_object_get_qdata (g_obj, (GQuark)dat);
+	res = g_hash_table_lookup(GOG_GRAPH(graph)->ref_counts, dat);
 
 	g_return_if_fail (res != NULL);
 
@@ -477,10 +487,13 @@
 			gog_graph_signals [GRAPH_REMOVE_DATA], 0, dat);
 		graph->data = g_slist_remove (graph->data, dat);
 		g_object_unref (dat);
-		g_object_set_qdata (g_obj, (GQuark)dat, NULL);
-	} else
+		//g_object_set_qdata (g_obj, (GQuark)dat, NULL);
+		g_hash_table_remove(GOG_GRAPH(graph)->ref_counts, dat);
+	} else {
 		/* store the decremented count */
-		g_object_set_qdata (g_obj, (GQuark)dat, GUINT_TO_POINTER (count));
+		//g_object_set_qdata (g_obj, (GQuark)dat, GUINT_TO_POINTER (count));
+		g_hash_table_insert(GOG_GRAPH(graph)->ref_counts, dat, GUINT_TO_POINTER (count));
+	}
 }
 
 static gboolean



More information about the gnucash-changes mailing list