2000-09-18 Gerd Moellmann <gerd@gnu.org>
+ * 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.
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;
}
{
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;
}
}
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;
}
}