From 9efcf193ef786d0dd33509911ad402e1bec04d22 Mon Sep 17 00:00:00 2001 From: Sanel Zukan Date: Wed, 14 Nov 2007 14:45:59 +0000 Subject: [PATCH] Let unneeded wallpaper resources be freed after image was drawn to rootpmap --- eiconman/Wallpaper.cpp | 39 ++++++++++++--------------------------- eiconman/Wallpaper.h | 1 - eiconman/eiconman.conf | 2 +- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/eiconman/Wallpaper.cpp b/eiconman/Wallpaper.cpp index 03317a4..0862ff6 100644 --- a/eiconman/Wallpaper.cpp +++ b/eiconman/Wallpaper.cpp @@ -40,19 +40,10 @@ tmp |= (((int)b >> (-bshift)) & bmask); -Pixmap create_xpixmap(Fl_Image* img, XImage* xim, Pixmap pix) { +Pixmap create_xpixmap(Fl_Image* img, XImage*& xim, Pixmap pix) { if(!img) return 0; - if(xim) { - if(xim->data) { - delete [] xim->data; - xim->data = 0; - } - XDestroyImage(xim); - xim = 0; - } - if(pix) XFreePixmap(fl_display, pix); @@ -107,16 +98,7 @@ Pixmap create_xpixmap(Fl_Image* img, XImage* xim, Pixmap pix) { else if(fl_visual->depth > 8) bitmap_pad = 16; else { - EWARNING(ESTRLOC ": Visual %i not supported\n", xim->bits_per_pixel); - - if(xim) { - if(xim->data) { - delete [] xim->data; - xim->data = 0; - } - XDestroyImage(xim); - xim = 0; - } + EWARNING(ESTRLOC ": Visual %i not supported\n", fl_visual->depth); return 0; } @@ -372,16 +354,10 @@ bool create_tile(Fl_Image* orig, Fl_RGB_Image*& copied, int X, int Y, int W, int } Wallpaper::Wallpaper(int X, int Y, int W, int H) : - Fl_Box(X, Y, W, H, 0), rootpmap_image(NULL), rootpmap_pixmap(0), tiled(false) { + Fl_Box(X, Y, W, H, 0), rootpmap_pixmap(0), tiled(false) { } Wallpaper::~Wallpaper() { - if(rootpmap_image) { - if(rootpmap_image->data) - delete [] rootpmap_image->data; - XDestroyImage(rootpmap_image); - } - if(rootpmap_pixmap) XFreePixmap(fl_display, rootpmap_pixmap); } @@ -429,8 +405,17 @@ void Wallpaper::set_rootpmap(void) { if(!image()) return; + XImage* rootpmap_image = 0; rootpmap_pixmap = create_xpixmap(image(), rootpmap_image, rootpmap_pixmap); + if(rootpmap_image) { + /* + * XDestroyImage function calls frees both the image structure and the + * data pointed to by the image structure. + */ + XDestroyImage(rootpmap_image); + } + if(!rootpmap_pixmap) return; diff --git a/eiconman/Wallpaper.h b/eiconman/Wallpaper.h index c965e7c..7658e55 100644 --- a/eiconman/Wallpaper.h +++ b/eiconman/Wallpaper.h @@ -23,7 +23,6 @@ */ class Wallpaper : public Fl_Box { private: - XImage* rootpmap_image; Pixmap rootpmap_pixmap; bool tiled; void set_rootpmap(void); diff --git a/eiconman/eiconman.conf b/eiconman/eiconman.conf index 7dfec45..1e19052 100644 --- a/eiconman/eiconman.conf +++ b/eiconman/eiconman.conf @@ -2,7 +2,7 @@ Color = 458855680 WallpaperUse = 1 WallpaperMode = 1 - Wallpaper = /home/sanel/wallpapers/janablack_02_1024.jpg + Wallpaper = /home/sanelz/walls/Something_Beautiful_by_mirrorkills.jpg [Icons] Label Background = 827223040