From f4779de9e96f656ca4f9a94059f0bb2deafdf748 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Mon, 18 Sep 2000 11:17:46 +0000 Subject: [PATCH] (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. --- src/ChangeLog | 5 +++++ src/xfns.c | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 77d4d1161c9..6ccc73fcd08 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ 2000-09-18 Gerd Moellmann + * xfns.c (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. + * xfns.c (lookup_image): Block input while loading the image so that we won't get interrupted in a state where the image isn't yet set up completely. diff --git a/src/xfns.c b/src/xfns.c index 9a171965b16..e34d36a8c06 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5526,24 +5526,29 @@ x_clear_image (f, img) struct frame *f; struct image *img; { + BLOCK_INPUT; + if (img->pixmap) { - BLOCK_INPUT; XFreePixmap (FRAME_X_DISPLAY (f), img->pixmap); img->pixmap = 0; - UNBLOCK_INPUT; + } + + if (img->mask) + { + XFreePixmap (FRAME_X_DISPLAY (f), img->mask); + img->mask = 0; } if (img->ncolors) { - BLOCK_INPUT; x_free_colors (f, img->colors, img->ncolors); - UNBLOCK_INPUT; - xfree (img->colors); img->colors = NULL; img->ncolors = 0; } + + UNBLOCK_INPUT; } @@ -5652,20 +5657,23 @@ clear_image_cache (f, force_p) { EMACS_TIME t; unsigned long old; - int i, any_freed_p = 0; + int i, nfreed; EMACS_GET_TIME (t); old = EMACS_SECS (t) - XFASTINT (Vimage_cache_eviction_delay); + + /* Block input so that we won't be interrupted by a SIGIO + while being in an inconsistent state. */ + BLOCK_INPUT; - for (i = 0; i < c->used; ++i) + for (i = nfreed = 0; i < c->used; ++i) { struct image *img = c->images[i]; if (img != NULL - && (force_p - || (img->timestamp > old))) + && (force_p || img->timestamp < old)) { free_image (f, img); - any_freed_p = 1; + ++nfreed; } } @@ -5673,11 +5681,22 @@ clear_image_cache (f, force_p) Emacs was iconified for a longer period of time. In that case, current matrices may still contain references to images freed above. So, clear these matrices. */ - if (any_freed_p) + if (nfreed) { - clear_current_matrices (f); + Lisp_Object tail, frame; + + FOR_EACH_FRAME (tail, frame) + { + struct frame *f = XFRAME (frame); + if (FRAME_X_P (f) + && FRAME_X_IMAGE_CACHE (f) == c) + clear_current_matrices (f); + } + ++windows_or_buffers_changed; } + + UNBLOCK_INPUT; } } -- 2.39.2