comparison src/xfns.c @ 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 4b5692f6703a
children a2208fe45c36
comparison
equal deleted inserted replaced
52090:3c8a655b53e0 52091:c3f9f23be6a8
621 if (! bitmap) 621 if (! bitmap)
622 return -1; 622 return -1;
623 623
624 id = x_allocate_bitmap_record (f); 624 id = x_allocate_bitmap_record (f);
625 dpyinfo->bitmaps[id - 1].pixmap = bitmap; 625 dpyinfo->bitmaps[id - 1].pixmap = bitmap;
626 dpyinfo->bitmaps[id - 1].have_mask = 0;
626 dpyinfo->bitmaps[id - 1].file = NULL; 627 dpyinfo->bitmaps[id - 1].file = NULL;
627 dpyinfo->bitmaps[id - 1].refcount = 1; 628 dpyinfo->bitmaps[id - 1].refcount = 1;
628 dpyinfo->bitmaps[id - 1].depth = 1; 629 dpyinfo->bitmaps[id - 1].depth = 1;
629 dpyinfo->bitmaps[id - 1].height = height; 630 dpyinfo->bitmaps[id - 1].height = height;
630 dpyinfo->bitmaps[id - 1].width = width; 631 dpyinfo->bitmaps[id - 1].width = width;
672 if (result != BitmapSuccess) 673 if (result != BitmapSuccess)
673 return -1; 674 return -1;
674 675
675 id = x_allocate_bitmap_record (f); 676 id = x_allocate_bitmap_record (f);
676 dpyinfo->bitmaps[id - 1].pixmap = bitmap; 677 dpyinfo->bitmaps[id - 1].pixmap = bitmap;
678 dpyinfo->bitmaps[id - 1].have_mask = 0;
677 dpyinfo->bitmaps[id - 1].refcount = 1; 679 dpyinfo->bitmaps[id - 1].refcount = 1;
678 dpyinfo->bitmaps[id - 1].file 680 dpyinfo->bitmaps[id - 1].file
679 = (char *) xmalloc (SBYTES (file) + 1); 681 = (char *) xmalloc (SBYTES (file) + 1);
680 dpyinfo->bitmaps[id - 1].depth = 1; 682 dpyinfo->bitmaps[id - 1].depth = 1;
681 dpyinfo->bitmaps[id - 1].height = height; 683 dpyinfo->bitmaps[id - 1].height = height;
699 --dpyinfo->bitmaps[id - 1].refcount; 701 --dpyinfo->bitmaps[id - 1].refcount;
700 if (dpyinfo->bitmaps[id - 1].refcount == 0) 702 if (dpyinfo->bitmaps[id - 1].refcount == 0)
701 { 703 {
702 BLOCK_INPUT; 704 BLOCK_INPUT;
703 XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap); 705 XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].pixmap);
704 XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].mask); 706 if (dpyinfo->bitmaps[id - 1].have_mask)
707 XFreePixmap (FRAME_X_DISPLAY (f), dpyinfo->bitmaps[id - 1].mask);
705 if (dpyinfo->bitmaps[id - 1].file) 708 if (dpyinfo->bitmaps[id - 1].file)
706 { 709 {
707 xfree (dpyinfo->bitmaps[id - 1].file); 710 xfree (dpyinfo->bitmaps[id - 1].file);
708 dpyinfo->bitmaps[id - 1].file = NULL; 711 dpyinfo->bitmaps[id - 1].file = NULL;
709 } 712 }
721 int i; 724 int i;
722 for (i = 0; i < dpyinfo->bitmaps_last; i++) 725 for (i = 0; i < dpyinfo->bitmaps_last; i++)
723 if (dpyinfo->bitmaps[i].refcount > 0) 726 if (dpyinfo->bitmaps[i].refcount > 0)
724 { 727 {
725 XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap); 728 XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].pixmap);
726 XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].mask); 729 if (dpyinfo->bitmaps[i].have_mask)
730 XFreePixmap (dpyinfo->display, dpyinfo->bitmaps[i].mask);
727 if (dpyinfo->bitmaps[i].file) 731 if (dpyinfo->bitmaps[i].file)
728 xfree (dpyinfo->bitmaps[i].file); 732 xfree (dpyinfo->bitmaps[i].file);
729 } 733 }
730 dpyinfo->bitmaps_last = 0; 734 dpyinfo->bitmaps_last = 0;
731 } 735 }
820 gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL); 824 gc = XCreateGC (FRAME_X_DISPLAY (f), mask, 0, NULL);
821 XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0, 825 XPutImage (FRAME_X_DISPLAY (f), mask, gc, mask_img, 0, 0, 0, 0,
822 width, height); 826 width, height);
823 XFreeGC (FRAME_X_DISPLAY (f), gc); 827 XFreeGC (FRAME_X_DISPLAY (f), gc);
824 828
829 dpyinfo->bitmaps[id - 1].have_mask = 1;
825 dpyinfo->bitmaps[id - 1].mask = mask; 830 dpyinfo->bitmaps[id - 1].mask = mask;
826 831
827 XDestroyImage (ximg); 832 XDestroyImage (ximg);
828 x_destroy_x_image(mask_img); 833 x_destroy_x_image(mask_img);
829 834