summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkImgBmap.c18
1 files 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;