From 72eafc841308ee69373cb7a5d038e4777956b997 Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Wed, 7 Dec 2005 01:34:44 +0000 Subject: [PATCH] Don't misuse the Quark storage for pointers, especially because they're not integer-sized on a 64-bit platform. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12140 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 7 +++++ .../goffice/graph/gog-graph-impl.h | 1 + lib/goffice-0.0.4/goffice/graph/gog-graph.c | 27 ++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4f5a2c3b5..6ef5824718 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-12-06 Joshua Sled + + * 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 * configure.in: remove libgsf/po/Makefile and goffice/po/Makefile diff --git a/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h b/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h index 43f3f13fcf..a7a3a6b758 100644 --- a/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h +++ b/lib/goffice-0.0.4/goffice/graph/gog-graph-impl.h @@ -35,6 +35,7 @@ struct _GogGraph { GogTheme *theme; GSList *charts; GSList *data; + GHashTable *ref_counts; unsigned num_cols, num_rows; double width, height; diff --git a/lib/goffice-0.0.4/goffice/graph/gog-graph.c b/lib/goffice-0.0.4/goffice/graph/gog-graph.c index 9f7266ef02..f9ddeaa2a1 100644 --- a/lib/goffice-0.0.4/goffice/graph/gog-graph.c +++ b/lib/goffice-0.0.4/goffice/graph/gog-graph.c @@ -118,6 +118,11 @@ gog_graph_finalize (GObject *obj) 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 @@ gog_graph_init (GogGraph *graph) 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 @@ gog_graph_ref_data (GogGraph *graph, GOData *dat) /* 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 @@ gog_graph_ref_data (GogGraph *graph, GOData *dat) 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 @@ gog_graph_unref_data (GogGraph *graph, GOData *dat) 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_unref_data (GogGraph *graph, GOData *dat) 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