Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: draw.c Log Message: Fix memory leak if translucent move initialisation fails. =================================================================== RCS file: /cvs/e/e16/e/src/draw.c,v retrieving revision 1.114 retrieving revision 1.115 diff -u -3 -r1.114 -r1.115 --- draw.c 13 Feb 2008 20:51:00 -0000 1.114 +++ draw.c 1 Mar 2008 15:38:59 -0000 1.115 @@ -253,6 +253,31 @@ EoShapeUpdate(sw, 0); } +static PixImg *root_pi = NULL; +static PixImg *ewin_pi = NULL; +static PixImg *draw_pi = NULL; + +static void +_PixImgsCreate(Window root, const EWin * ewin) +{ + root_pi = ECreatePixImg(root, VRoot.w, VRoot.h); + ewin_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin)); + draw_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin)); +} + +static void +_PixImgsDestroy(void) +{ + EDestroyPixImg(root_pi); + EDestroyPixImg(ewin_pi); + EDestroyPixImg(draw_pi); + EBlendRemoveShape(NULL, 0, 0, 0); + EBlendPixImg(NULL, NULL, NULL, NULL, 0, 0, 0, 0); + root_pi = NULL; + ewin_pi = NULL; + draw_pi = NULL; +} + void DrawEwinShape(EWin * ewin, int md, int x, int y, int w, int h, int firstlast, int seqno) @@ -389,28 +414,15 @@ break; case 5: { - static PixImg *ewin_pi = NULL; - static PixImg *root_pi = NULL; - static PixImg *draw_pi = NULL; - if (firstlast == 0) { - XGCValues gcv2; GC gc2; - if (ewin_pi) - EDestroyPixImg(ewin_pi); - if (root_pi) - EDestroyPixImg(root_pi); - if (draw_pi) - EDestroyPixImg(draw_pi); - EBlendRemoveShape(NULL, 0, 0, 0); - EBlendPixImg(NULL, NULL, NULL, NULL, 0, 0, 0, 0); - root_pi = ECreatePixImg(root, VRoot.w, VRoot.h); - ewin_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin)); - draw_pi = ECreatePixImg(root, EoGetW(ewin), EoGetH(ewin)); + _PixImgsDestroy(); + _PixImgsCreate(root, ewin); if ((!root_pi) || (!ewin_pi) || (!draw_pi)) { + _PixImgsDestroy(); Conf.movres.mode_move = 0; EUngrabServer(); DrawEwinShape(ewin, Conf.movres.mode_move, x, y, w, h, @@ -419,7 +431,7 @@ } EFillPixmap(root, root_pi->pmap, x1, y1, EoGetW(ewin), EoGetH(ewin)); - gc2 = EXCreateGC(root_pi->pmap, 0, &gcv2); + gc2 = EXCreateGC(root_pi->pmap, 0, NULL); XCopyArea(disp, root_pi->pmap, ewin_pi->pmap, gc2, x1, y1, EoGetW(ewin), EoGetH(ewin), 0, 0); EXFreeGC(gc2); @@ -485,17 +497,7 @@ { EPastePixmap(root, root_pi->pmap, x1, y1, EoGetW(ewin), EoGetH(ewin)); - if (ewin_pi) - EDestroyPixImg(ewin_pi); - if (root_pi) - EDestroyPixImg(root_pi); - if (draw_pi) - EDestroyPixImg(draw_pi); - EBlendRemoveShape(NULL, 0, 0, 0); - EBlendPixImg(NULL, NULL, NULL, NULL, 0, 0, 0, 0); - ewin_pi = NULL; - root_pi = NULL; - draw_pi = NULL; + _PixImgsDestroy(); } else if (firstlast == 3) { ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs