comparison src/xfns.c @ 31688:437830e83b45

(clear_image_cache): Clear current matrices of all frames sharing an image cache. Block input while freeing images. Fix timestamp comparison. (x_clear_image): Also free the mask.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 18 Sep 2000 11:17:23 +0000
parents 577372d71de8
children 8e9fb2a048ac
comparison
equal deleted inserted replaced
31687:091669fc1dba 31688:437830e83b45
5524 static void 5524 static void
5525 x_clear_image (f, img) 5525 x_clear_image (f, img)
5526 struct frame *f; 5526 struct frame *f;
5527 struct image *img; 5527 struct image *img;
5528 { 5528 {
5529 BLOCK_INPUT;
5530
5529 if (img->pixmap) 5531 if (img->pixmap)
5530 { 5532 {
5531 BLOCK_INPUT;
5532 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); 5533 XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap);
5533 img->pixmap = 0; 5534 img->pixmap = 0;
5534 UNBLOCK_INPUT; 5535 }
5536
5537 if (img->mask)
5538 {
5539 XFreePixmap (FRAME_X_DISPLAY (f), img->mask);
5540 img->mask = 0;
5535 } 5541 }
5536 5542
5537 if (img->ncolors) 5543 if (img->ncolors)
5538 { 5544 {
5539 BLOCK_INPUT;
5540 x_free_colors (f, img->colors, img->ncolors); 5545 x_free_colors (f, img->colors, img->ncolors);
5541 UNBLOCK_INPUT;
5542
5543 xfree (img->colors); 5546 xfree (img->colors);
5544 img->colors = NULL; 5547 img->colors = NULL;
5545 img->ncolors = 0; 5548 img->ncolors = 0;
5546 } 5549 }
5550
5551 UNBLOCK_INPUT;
5547 } 5552 }
5548 5553
5549 5554
5550 /* Allocate color COLOR_NAME for image IMG on frame F. If color 5555 /* Allocate color COLOR_NAME for image IMG on frame F. If color
5551 cannot be allocated, use DFLT. Add a newly allocated color to 5556 cannot be allocated, use DFLT. Add a newly allocated color to
5650 5655
5651 if (c && INTEGERP (Vimage_cache_eviction_delay)) 5656 if (c && INTEGERP (Vimage_cache_eviction_delay))
5652 { 5657 {
5653 EMACS_TIME t; 5658 EMACS_TIME t;
5654 unsigned long old; 5659 unsigned long old;
5655 int i, any_freed_p = 0; 5660 int i, nfreed;
5656 5661
5657 EMACS_GET_TIME (t); 5662 EMACS_GET_TIME (t);
5658 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); 5663 old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay);
5664
5665 /* Block input so that we won't be interrupted by a SIGIO
5666 while being in an inconsistent state. */
5667 BLOCK_INPUT;
5659 5668
5660 for (i = 0; i < c->used; ++i) 5669 for (i = nfreed = 0; i < c->used; ++i)
5661 { 5670 {
5662 struct image *img = c->images[i]; 5671 struct image *img = c->images[i];
5663 if (img != NULL 5672 if (img != NULL
5664 && (force_p 5673 && (force_p || img->timestamp < old))
5665 || (img->timestamp > old)))
5666 { 5674 {
5667 free_image (f, img); 5675 free_image (f, img);
5668 any_freed_p = 1; 5676 ++nfreed;
5669 } 5677 }
5670 } 5678 }
5671 5679
5672 /* We may be clearing the image cache because, for example, 5680 /* We may be clearing the image cache because, for example,
5673 Emacs was iconified for a longer period of time. In that 5681 Emacs was iconified for a longer period of time. In that
5674 case, current matrices may still contain references to 5682 case, current matrices may still contain references to
5675 images freed above. So, clear these matrices. */ 5683 images freed above. So, clear these matrices. */
5676 if (any_freed_p) 5684 if (nfreed)
5677 { 5685 {
5678 clear_current_matrices (f); 5686 Lisp_Object tail, frame;
5687
5688 FOR_EACH_FRAME (tail, frame)
5689 {
5690 struct frame *f = XFRAME (frame);
5691 if (FRAME_X_P (f)
5692 && FRAME_X_IMAGE_CACHE (f) == c)
5693 clear_current_matrices (f);
5694 }
5695
5679 ++windows_or_buffers_changed; 5696 ++windows_or_buffers_changed;
5680 } 5697 }
5698
5699 UNBLOCK_INPUT;
5681 } 5700 }
5682 } 5701 }
5683 5702
5684 5703
5685 DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache, 5704 DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,