# HG changeset patch # User Gerd Moellmann # Date 969275843 0 # Node ID 437830e83b4507d879fd05a4e566d4b377f9c0ec # Parent 091669fc1dbad6280de365cabb79ba85d0e9d488 (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. diff -r 091669fc1dba -r 437830e83b45 src/xfns.c --- a/src/xfns.c Mon Sep 18 10:52:08 2000 +0000 +++ b/src/xfns.c Mon Sep 18 11:17:23 2000 +0000 @@ -5526,24 +5526,29 @@ 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 @@ { 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 @@ 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; } }