# HG changeset patch # User giacomo # Date 1174501189 25200 # Node ID 13cdd6999598f298d26e62eff2078a7a5ba1aba8 # Parent 7e24265fe5406ebaebc0d0a7ca445829178e7366 [svn] - aosd: fixed ugly memleak in ghosd sources diff -r 7e24265fe540 -r 13cdd6999598 ChangeLog --- a/ChangeLog Wed Mar 21 07:36:32 2007 -0700 +++ b/ChangeLog Wed Mar 21 11:19:49 2007 -0700 @@ -1,3 +1,10 @@ +2007-03-21 14:36:32 +0000 Giacomo Lozito + revision [1876] + alsa: small changes + trunk/src/alsa/audio.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + + 2007-03-21 14:24:33 +0000 Giacomo Lozito revision [1874] aosd: use g_locale_to_utf8 for osd strings (needs testing) diff -r 7e24265fe540 -r 13cdd6999598 src/aosd/ghosd-internal.h --- a/src/aosd/ghosd-internal.h Wed Mar 21 07:36:32 2007 -0700 +++ b/src/aosd/ghosd-internal.h Wed Mar 21 11:19:49 2007 -0700 @@ -20,13 +20,18 @@ void *data; } EventButtonCallback; +typedef struct { + Pixmap pixmap; + int set; +} GhosdBackground; + struct _Ghosd { Display *dpy; Window win; int transparent; int x, y, width, height; - - Pixmap background; + + GhosdBackground background; RenderCallback render; EventButtonCallback eventbutton; }; diff -r 7e24265fe540 -r 13cdd6999598 src/aosd/ghosd.c --- a/src/aosd/ghosd.c Wed Mar 21 07:36:32 2007 -0700 +++ b/src/aosd/ghosd.c Wed Mar 21 11:19:49 2007 -0700 @@ -72,7 +72,7 @@ gc = XCreateGC(ghosd->dpy, pixmap, 0, NULL); if (ghosd->transparent) { - XCopyArea(ghosd->dpy, ghosd->background, pixmap, gc, + XCopyArea(ghosd->dpy, ghosd->background.pixmap, pixmap, gc, 0, 0, ghosd->width, ghosd->height, 0, 0); } else { XFillRectangle(ghosd->dpy, pixmap, gc, @@ -98,6 +98,7 @@ cairo_t *cr = cairo_create(surf); ghosd->render.func(ghosd, cr, ghosd->render.data); cairo_destroy(cr); + cairo_surface_destroy(surf); } /* point window at its new backing pixmap. */ @@ -192,9 +193,13 @@ void ghosd_show(Ghosd *ghosd) { if (ghosd->transparent) { - if (ghosd->background) - XFreePixmap(ghosd->dpy, ghosd->background); - ghosd->background = take_snapshot(ghosd); + if (ghosd->background.set) + { + XFreePixmap(ghosd->dpy, ghosd->background.pixmap); + ghosd->background.set = 0; + } + ghosd->background.pixmap = take_snapshot(ghosd); + ghosd->background.set = 1; } ghosd_render(ghosd); @@ -282,14 +287,18 @@ ghosd->win = win; ghosd->transparent = 1; ghosd->eventbutton.func = NULL; + ghosd->background.set = 0; return ghosd; } void ghosd_destroy(Ghosd* ghosd) { - if (ghosd->background) - XFreePixmap(ghosd->dpy, ghosd->background); + if (ghosd->background.set) + { + XFreePixmap(ghosd->dpy, ghosd->background.pixmap); + ghosd->background.set = 0; + } XDestroyWindow(ghosd->dpy, ghosd->win); }