From e4a39867867a5e7241f1dc928fbef189a909847b Mon Sep 17 00:00:00 2001 From: stanton Date: Thu, 4 Feb 1999 20:56:15 +0000 Subject: * generic/tkImgBmap.c (ImgBmapConfigureInstance): If an image mask changed but ended up with the same XID, the GC failed to be updated and so the new mask was not used. [Bug: 970] --- generic/tkImgBmap.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index d3e9f41..d7be9de 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkImgBmap.c,v 1.4 1998/09/14 18:23:12 stanton Exp $ + * RCS: @(#) $Id: tkImgBmap.c,v 1.5 1999/02/04 20:56:15 stanton Exp $ */ #include "tkInt.h" @@ -340,6 +340,7 @@ ImgBmapConfigureInstance(instancePtr) XGCValues gcValues; GC gc; unsigned int mask; + Pixmap oldMask; /* * For each of the options in masterPtr, translate the string @@ -382,10 +383,14 @@ ImgBmapConfigureInstance(instancePtr) (unsigned) masterPtr->height); } - if (instancePtr->mask != None) { - Tk_FreePixmap(Tk_Display(instancePtr->tkwin), instancePtr->mask); - instancePtr->mask = None; - } + /* + * Careful: We have to allocate a new mask Pixmap before deleting + * the old one. Otherwise, The XID allocator will always return + * the same XID for the new Pixmap as was used for the old Pixmap. + * And that will prevent the mask from changing in the GC below. + */ + oldMask = instancePtr->mask; + instancePtr->mask = None; if (masterPtr->maskData != NULL) { instancePtr->mask = XCreateBitmapFromData( Tk_Display(instancePtr->tkwin), @@ -393,6 +398,9 @@ ImgBmapConfigureInstance(instancePtr) masterPtr->maskData, (unsigned) masterPtr->width, (unsigned) masterPtr->height); } + if (oldMask != None) { + Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); + } if (masterPtr->data != NULL) { gcValues.foreground = instancePtr->fg->pixel; -- cgit v0.12