Enlightenment CVS committal Author : kwo Project : e17 Module : libs/imlib2
Dir : e17/libs/imlib2/src/lib Modified Files: Imlib2.h api.c rend.c rend.h Log Message: Introduce imlib_context_disconnect_display(). imlib_context_disconnect_display() should be called when a display connection is closed but the application continues using imlib2 with a different display connection. This is required to avoid to attempt to free cached GCs (in __imlib_RenderImage) after the associated display connection has been closed. It is not unlikely that similar cleanups should be performed elsewhere in this situation, but the __imlib_RenderImage GCs is the only case I have found to cause trouble so far. =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/Imlib2.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- Imlib2.h 27 Jul 2007 18:46:11 -0000 1.7 +++ Imlib2.h 13 Aug 2008 17:55:16 -0000 1.8 @@ -131,6 +131,7 @@ /* context setting */ # ifndef X_DISPLAY_MISSING EAPI void imlib_context_set_display(Display * display); + EAPI void imlib_context_disconnect_display(void); EAPI void imlib_context_set_visual(Visual * visual); EAPI void imlib_context_set_colormap(Colormap colormap); EAPI void imlib_context_set_drawable(Drawable drawable); =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/api.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- api.c 7 May 2008 21:38:39 -0000 1.21 +++ api.c 13 Aug 2008 17:55:16 -0000 1.22 @@ -314,8 +314,8 @@ } #ifdef BUILD_X11 -/** - * @param display Current display to bu used. +/** + * @param display Current display to be used. * * Sets the current X display to be used for rendering of images to * drawables. You do not need to set this if you do not intend to @@ -343,6 +343,22 @@ { CHECK_CONTEXT(ctx); return ctx->display; +} + +/** + * Tell Imlib2 that the current display connection has been closed. + * + * Call when (and only when) you close a display connection but continue + * using Imlib2 on a different connection. + */ +EAPI void +imlib_context_disconnect_display(void) +{ + CHECK_CONTEXT(ctx); + if (!ctx->display) + return; + __imlib_RenderDisconnect(ctx->display); + ctx->display = NULL; } /** =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/rend.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- rend.c 20 May 2007 13:26:25 -0000 1.7 +++ rend.c 13 Aug 2008 17:55:16 -0000 1.8 @@ -235,6 +235,21 @@ } } +static Display *disp = NULL; +static GC gc = NULL; +static GC gcm = NULL; +static int last_depth = 0; + +void +__imlib_RenderDisconnect(Display * d) +{ + if (d != disp) + return; + disp = NULL; + gc = gcm = NULL; + last_depth = 0; +} + void __imlib_RenderImage(Display * d, ImlibImage * im, Drawable w, Drawable m, @@ -248,10 +263,6 @@ Context *ct; DATA32 *buf = NULL, *pointer = NULL, *back = NULL; int y, h, hh, jump; - static Display *disp = NULL; - static int last_depth = 0; - static GC gc = 0; - static GC gcm = 0; XGCValues gcv; ImlibScaleInfo *scaleinfo = NULL; int psx, psy, psw, psh; =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/rend.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- rend.h 5 Sep 2006 18:50:35 -0000 1.3 +++ rend.h 13 Aug 2008 17:55:16 -0000 1.4 @@ -7,6 +7,9 @@ __imlib_RenderGetPixel(Display *d, Drawable w, Visual *v, Colormap cm, int depth, DATA8 r, DATA8 g, DATA8 b); __hidden void +__imlib_RenderDisconnect(Display *d); + +__hidden void __imlib_RenderImage(Display *d, ImlibImage *im, Drawable w, Drawable m, Visual *v, Colormap cm, int depth, ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs