diff options
| author | Gerd Moellmann | 2000-09-18 11:17:46 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-09-18 11:17:46 +0000 |
| commit | f4779de9e96f656ca4f9a94059f0bb2deafdf748 (patch) | |
| tree | 28d1be946f747a31284f18ba99241602945752e0 /src | |
| parent | 28c7826c71a60f6a980d3064a449c51401d10b5b (diff) | |
| download | emacs-f4779de9e96f656ca4f9a94059f0bb2deafdf748.tar.gz emacs-f4779de9e96f656ca4f9a94059f0bb2deafdf748.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2000-09-18 Gerd Moellmann <gerd@gnu.org> | 1 | 2000-09-18 Gerd Moellmann <gerd@gnu.org> |
| 2 | 2 | ||
| 3 | * xfns.c (clear_image_cache): Clear current matrices of all | ||
| 4 | frames sharing an image cache. Block input while freeing | ||
| 5 | images. Fix timestamp comparison. | ||
| 6 | (x_clear_image): Also free the mask. | ||
| 7 | |||
| 3 | * xfns.c (lookup_image): Block input while loading the image so | 8 | * xfns.c (lookup_image): Block input while loading the image so |
| 4 | that we won't get interrupted in a state where the image isn't yet | 9 | that we won't get interrupted in a state where the image isn't yet |
| 5 | set up completely. | 10 | 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) | |||
| 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 | ||
| @@ -5652,20 +5657,23 @@ clear_image_cache (f, force_p) | |||
| 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 | ||
| @@ -5673,11 +5681,22 @@ clear_image_cache (f, force_p) | |||
| 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 | ||