diff options
author | mdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2012-05-23 21:32:10 +0000 |
---|---|---|
committer | mdankov <mdankov@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2012-05-23 21:32:10 +0000 |
commit | c4e643a5c172da544566e7c5a15990568a3f2686 (patch) | |
tree | 642a1f031f0a0b3352af1c3fbb7dee56f4980c0b /navit/graphics.c | |
parent | a88cd602770a2c12773ea3cc6c14d1c0a3d48ab1 (diff) | |
download | navit-svn-c4e643a5c172da544566e7c5a15990568a3f2686.tar.gz |
Fix:core:Made graphics.c code compatible with n800 again.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5112 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/graphics.c')
-rw-r--r-- | navit/graphics.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/navit/graphics.c b/navit/graphics.c index 62d8af95..71fe28fa 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -245,7 +245,7 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs) this_->contrast=65536; this_->gamma=65536; this_->font_size=20; - this_->image_cache_hash = g_hash_table_new(g_str_hash, g_str_equal); + this_->image_cache_hash = g_hash_table_new_full(g_str_hash, g_str_equal,g_free,g_free); while (*attrs) { graphics_set_attr_do(this_,*attrs); attrs++; @@ -411,14 +411,18 @@ void graphics_free(struct graphics *gra) GHashTableIter iter; char *key; struct graphics_image *img; - g_hash_table_iter_init (&iter, gra->image_cache_hash); - while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &img)) { - g_hash_table_iter_remove (&iter); - g_free(key); + GList *l; + + /* We can't specify context (pointer to struct graphics) for g_hash_table_new to have it passed to free function + so we have to free img->priv manually, the rest would be freed by g_hash_table_destroy. GHashTableIter isn't used because it + broke n800 build at r5107. + */ + for(l=g_hash_table_get_values(gra->image_cache_hash);l;l=g_list_next(l)) { + img=l->data; if (img && gra->meth.image_free) gra->meth.image_free(gra->priv, img->priv); - g_free(img); } + g_hash_table_destroy(gra->image_cache_hash); } graphics_gc_destroy(gra->gc[0]); |