changeset 52091:c3f9f23be6a8

(x_create_bitmap_from_data): Initialize have_mask member to 0. (x_create_bitmap_from_file): Likewise. (x_destroy_bitmap): Check have_mask member before freeing a mask. (x_destroy_all_bitmaps): Likewise. (x_create_bitmap_mask): Set have_mask member to 1.
author Kenichi Handa <handa@m17n.org>
date Thu, 31 Jul 2003 00:52:00 +0000
parents 3c8a655b53e0
children ef0c4b13c02b
files src/xfns.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Thu Jul 31 00:51:34 2003 +0000
+++ b/src/xfns.c	Thu Jul 31 00:52:00 2003 +0000
@@ -623,6 +623,7 @@
 
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
+  dpyinfo->bitmaps[id - 1].have_mask = 0;
   dpyinfo->bitmaps[id - 1].file = NULL;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].depth = 1;
@@ -674,6 +675,7 @@
 
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
+  dpyinfo->bitmaps[id - 1].have_mask = 0;
   dpyinfo->bitmaps[id - 1].refcount = 1;
   dpyinfo->bitmaps[id - 1].file
     = (char *) xmalloc (SBYTES (file) + 1);
@@ -701,7 +703,8 @@
 	{
 	  BLOCK_INPUT;
 	  XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap);
-	  XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].mask);
+	  if (dpyinfo->bitmaps[id - 1].have_mask)
+	    XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].mask);
 	  if (dpyinfo->bitmaps[id - 1].file)
 	    {
 	      xfree (dpyinfo->bitmaps[id - 1].file);
@@ -723,7 +726,8 @@
     if (dpyinfo->bitmaps[i].refcount > 0)
       {
 	XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap);
-	XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].mask);
+	if (dpyinfo->bitmaps[i].have_mask)
+	  XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].mask);
 	if (dpyinfo->bitmaps[i].file)
 	  xfree (dpyinfo->bitmaps[i].file);
       }
@@ -822,6 +826,7 @@
 	     width, height);
   XFreeGC (FRAME_X_DISPLAY (f), gc);
 
+  dpyinfo->bitmaps[id - 1].have_mask = 1;
   dpyinfo->bitmaps[id - 1].mask = mask;
 
   XDestroyImage (ximg);