Hi all,

This patch prevent memory leak when user want to change the image of the 
widget (image.c) by calling lite_load_image multiple times.

BR,
Keith


diff --git a/leck/image.c b/leck/image.c
index 7dd92de..9f03ff9 100644
--- a/leck/image.c
+++ b/leck/image.c
@@ -66,6 +66,7 @@ lite_new_image(LiteBox        *parent,
      image->box.parent = parent;
      image->theme = theme;
      image->box.rect = *rect;
+     image->surface = NULL;
 
      res = lite_init_box(LITE_BOX(image));
      if (res != DFB_OK) {
@@ -96,6 +97,11 @@ lite_load_image(LiteImage *image, const char *filename)
 
      D_DEBUG_AT(LiteImageDomain, "Load image from file: %s\n", filename);
 
+     if (image->surface) {
+          image->surface->Release(image->surface);
+          image->surface = NULL;
+     }
+
      res = lite_util_load_image(filename, DSPF_UNKNOWN, &image->surface,
                                &image->width, &image->height, NULL);
      if(res != DFB_OK)


_______________________________________________
directfb-dev mailing list
directfb-dev@directfb.org
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to