[maemo-commits] [maemo-commits] r13756 - in projects/haf/trunk/sapwood: . src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Sep 11 16:59:41 EEST 2007
- Previous message: [maemo-commits] r13755 - in projects/haf/trunk/sapwood: . src
- Next message: [maemo-commits] r13757 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: tko Date: 2007-09-11 16:59:39 +0300 (Tue, 11 Sep 2007) New Revision: 13756 Modified: projects/haf/trunk/sapwood/ChangeLog projects/haf/trunk/sapwood/src/sapwood-server.c Log: Add reference counting to pixmaps. 2007-09-11 Tommi Komulainen <tommi.komulainen at nokia.com> * src/sapwood-server.c (process_buffer, cleanup_sock_removed): Add reference counting to pixmaps. It is already possible for one client to request the same pixmap multiple times, but the first release will invalidate all instances. Modified: projects/haf/trunk/sapwood/ChangeLog =================================================================== --- projects/haf/trunk/sapwood/ChangeLog 2007-09-11 13:54:48 UTC (rev 13755) +++ projects/haf/trunk/sapwood/ChangeLog 2007-09-11 13:59:39 UTC (rev 13756) @@ -1,5 +1,12 @@ 2007-09-11 Tommi Komulainen <tommi.komulainen at nokia.com> + * src/sapwood-server.c (process_buffer, cleanup_sock_removed): Add + reference counting to pixmaps. It is already possible for one client + to request the same pixmap multiple times, but the first release will + invalidate all instances. + +2007-09-11 Tommi Komulainen <tommi.komulainen at nokia.com> + * src/sapwood-pixmap.c (sapwood_pixmap_get_for_file) * src/sapwood-render.c (theme_pixbuf_set_filename): Resolve symbolic links before using the path as cache key. Otherwise when switching Modified: projects/haf/trunk/sapwood/src/sapwood-server.c =================================================================== --- projects/haf/trunk/sapwood/src/sapwood-server.c 2007-09-11 13:54:48 UTC (rev 13755) +++ projects/haf/trunk/sapwood/src/sapwood-server.c 2007-09-11 13:59:39 UTC (rev 13756) @@ -53,6 +53,11 @@ static const char *sock_path; +typedef struct { + PixbufOpenResponse *rep; + guint refcnt; +} CacheNode; + #ifndef HAVE_ABSTRACT_SOCKETS static void atexit_handler (void) @@ -356,8 +361,19 @@ rep = g_cache_insert (pixmap_cache, req); if (rep) { - g_hash_table_insert (cleanup, GUINT_TO_POINTER(rep->id), rep); + CacheNode *node; + node = g_hash_table_lookup (cleanup, GUINT_TO_POINTER(rep->id)); + if (!node) + { + node = g_new(CacheNode, 1); + node->rep = rep; + node->refcnt = 1; + g_hash_table_insert (cleanup, GUINT_TO_POINTER(rep->id), node); + } + else + node->refcnt++; + /* write reply */ n = write (fd, rep, sizeof (*rep)); if (n < 0) @@ -381,6 +397,7 @@ else if (base->op == PIXBUF_OP_CLOSE) { PixbufCloseRequest *req = (PixbufCloseRequest *) base; + CacheNode *node; if (base->length < sizeof (PixbufCloseRequest)) { @@ -389,7 +406,17 @@ return -1; } - if (!g_hash_table_remove (cleanup, GUINT_TO_POINTER(req->id))) + node = g_hash_table_lookup (cleanup, GUINT_TO_POINTER(req->id)); + if (node) + { + node->refcnt--; + if (node->refcnt == 0) + { + g_hash_table_remove (cleanup, GUINT_TO_POINTER(req->id)); + g_free (node); + } + } + else g_warning ("close failed, no such pixmap"); /* no reply */ @@ -468,7 +495,8 @@ static void cleanup_pixmap_destroy (gpointer data) { - g_cache_remove (pixmap_cache, data); + CacheNode *node = data; + g_cache_remove (pixmap_cache, node->rep); } static gboolean
- Previous message: [maemo-commits] r13755 - in projects/haf/trunk/sapwood: . src
- Next message: [maemo-commits] r13757 - in projects/haf/trunk/sapwood: . src
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]