emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/image.c,v


From: Stefan Monnier
Subject: [Emacs-diffs] Changes to emacs/src/image.c,v
Date: Sun, 24 Feb 2008 13:36:40 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Stefan Monnier <monnier>        08/02/24 13:36:39

Index: src/image.c
===================================================================
RCS file: /sources/emacs/emacs/src/image.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- src/image.c 22 Feb 2008 17:45:11 -0000      1.96
+++ src/image.c 24 Feb 2008 13:36:38 -0000      1.97
@@ -1184,9 +1184,11 @@
      unsigned hash;
 {
   struct image *img = (struct image *) xmalloc (sizeof *img);
+  Lisp_Object file = image_spec_value (spec, QCfile, NULL);
 
   xassert (valid_image_p (spec));
   bzero (img, sizeof *img);
+  img->dependencies = NILP (file) ? Qnil : list1 (file);
   img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
   xassert (img->type != NULL);
   img->spec = spec;
@@ -1707,21 +1709,20 @@
 }
 
 
-/* Clear image cache of frame F.  FORCE_P non-zero means free all
-   images.  FORCE_P zero means clear only images that haven't been
-   displayed for some time.  Should be called from time to time to
-   reduce the number of loaded images.  If image-cache-eviction-delay
-   is non-nil, this frees images in the cache which weren't displayed
-   for at least that many seconds.  */
+/* Clear image cache of frame F.  FILTER=t means free all images.
+   FILTER=nil means clear only images that haven't been
+   displayed for some time.
+   Else, only free the images which have FILTER in their `dependencies'.
+   Should be called from time to time to reduce the number of loaded images.
+   If image-cache-eviction-delay is non-nil, this frees images in the cache
+   which weren't displayed for at least that many seconds.  */
 
 void
-clear_image_cache (f, force_p)
-     struct frame *f;
-     int force_p;
+clear_image_cache (struct frame *f, Lisp_Object filter)
 {
   struct image_cache *c = FRAME_IMAGE_CACHE (f);
 
-  if (c && INTEGERP (Vimage_cache_eviction_delay))
+  if (c && (!NILP (filter) || INTEGERP (Vimage_cache_eviction_delay)))
     {
       EMACS_TIME t;
       unsigned long old;
@@ -1738,7 +1739,9 @@
        {
          struct image *img = c->images[i];
          if (img != NULL
-             && (force_p || img->timestamp < old))
+             && (NILP (filter) ? img->timestamp < old
+                 : (EQ (Qt, filter)
+                    || !NILP (Fmember (filter, img->dependencies)))))
            {
              free_image (f, img);
              ++nfreed;
@@ -1768,7 +1771,7 @@
 }
 
 void
-clear_image_caches (int force_p)
+clear_image_caches (Lisp_Object filter)
 {
   /* FIXME: We want to do
    * struct terminal *t;
@@ -1777,21 +1780,23 @@
   Lisp_Object tail, frame;
   FOR_EACH_FRAME (tail, frame)
     if (FRAME_WINDOW_P (XFRAME (frame)))
-      clear_image_cache (XFRAME (frame), force_p);
+      clear_image_cache (XFRAME (frame), filter);
 }
 
 DEFUN ("clear-image-cache", Fclear_image_cache, Sclear_image_cache,
        0, 1, 0,
-       doc: /* Clear the image cache of FRAME.
-FRAME nil or omitted means use the selected frame.
-FRAME t means clear the image caches of all frames.  */)
-     (frame)
-     Lisp_Object frame;
+       doc: /* Clear the image cache.
+FILTER nil or a frame means clear all images in the selected frame.
+FILTER t means clear the image caches of all frames.
+Anything else, means only clear those images which refer to FILTER,
+which is then usually a filename.  */)
+     (filter)
+     Lisp_Object filter;
 {
-  if (EQ (frame, Qt))
-    clear_image_caches (1);
+  if (!(EQ (filter, Qnil) || FRAMEP (filter)))
+    clear_image_caches (filter);
   else
-    clear_image_cache (check_x_frame (frame), 1);
+    clear_image_cache (check_x_frame (filter), Qt);
 
   return Qnil;
 }
@@ -2074,6 +2079,7 @@
      struct image *img;
 {
   mark_object (img->spec);
+  mark_object (img->dependencies);
 
   if (!NILP (img->data.lisp_val))
     mark_object (img->data.lisp_val);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]