mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-29 04:04:07 -06:00
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
This commit is contained in:
parent
e10c938b27
commit
72eafc8413
@ -1,3 +1,10 @@
|
||||
2005-12-06 Joshua Sled <jsled@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@ihtfp.com>
|
||||
|
||||
* configure.in: remove libgsf/po/Makefile and goffice/po/Makefile
|
||||
|
@ -35,6 +35,7 @@ struct _GogGraph {
|
||||
GogTheme *theme;
|
||||
GSList *charts;
|
||||
GSList *data;
|
||||
GHashTable *ref_counts;
|
||||
|
||||
unsigned num_cols, num_rows;
|
||||
double width, height;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user