[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 8c68e4a: * src/buffer.c (Fmove_overlay): Don't call
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 8c68e4a: * src/buffer.c (Fmove_overlay): Don't call Fdelete_overlay |
Date: |
Sun, 14 Oct 2018 16:44:26 -0400 (EDT) |
branch: master
commit 8c68e4afa8eebb6f738fdce600a6815509ac50a3
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* src/buffer.c (Fmove_overlay): Don't call Fdelete_overlay
... because the data structure is not in a consistent state.
* test/src/buffer-tests.el (overlay-evaporation-after-killed-buffer):
New test.
---
src/buffer.c | 22 +++++++++++++++++++++-
test/src/buffer-tests.el | 15 +++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/src/buffer.c b/src/buffer.c
index 024e64f..ac2de7d 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3991,6 +3991,16 @@ buffer. */)
unchain_both (ob, overlay);
}
+ else
+ /* An overlay not associated with any buffer will normally have its
+ `next' field set to NULL, but not always: when killing a buffer,
+ we just set its overlays_after and overlays_before to NULL without
+ manually setting each overlay's `next' field to NULL.
+ Let's correct it here, to simplify subsequent assertions.
+ FIXME: Maybe the better fix is to change `kill-buffer'!? */
+ XOVERLAY (overlay)->next = NULL;
+
+ eassert (XOVERLAY (overlay)->next == NULL);
/* Set the overlay boundaries, which may clip them. */
Fset_marker (OVERLAY_START (overlay), beg, buffer);
@@ -4020,10 +4030,20 @@ buffer. */)
modify_overlay (b, min (o_beg, n_beg), max (o_end, n_end));
}
+ eassert (XOVERLAY (overlay)->next == NULL);
+
/* Delete the overlay if it is empty after clipping and has the
evaporate property. */
if (n_beg == n_end && !NILP (Foverlay_get (overlay, Qevaporate)))
- return unbind_to (count, Fdelete_overlay (overlay));
+ { /* We used to call `Fdelete_overlay' here, but it causes problems:
+ - At this stage, `overlay' is not included in its buffer's lists
+ of overlays (the data-structure is in an inconsistent state),
+ contrary to `Fdelete_overlay's assumptions.
+ - Most of the work done by Fdelete_overlay has already been done
+ here for other reasons. */
+ drop_overlay (XBUFFER (buffer), XOVERLAY (overlay));
+ return unbind_to (count, overlay);
+ }
/* Put the overlay into the new buffer's overlay lists, first on the
wrong list. */
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 0e4fd36..609585f 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -79,4 +79,19 @@ with parameters from the *Messages* buffer modification."
(with-temp-buffer
(should (eq (buffer-base-buffer (current-buffer)) nil))))
+(ert-deftest overlay-evaporation-after-killed-buffer ()
+ (let* ((ols (with-temp-buffer
+ (insert "toto")
+ (list
+ (make-overlay (point-min) (point-max))
+ (make-overlay (point-min) (point-max))
+ (make-overlay (point-min) (point-max)))))
+ (ol (nth 1 ols)))
+ (overlay-put ol 'evaporate t)
+ ;; Evaporation within move-overlay of an overlay that was deleted because
+ ;; of a kill-buffer, triggered an assertion failure in unchain_both.
+ (with-temp-buffer
+ (insert "toto")
+ (move-overlay ol (point-min) (point-min)))))
+
;;; buffer-tests.el ends here
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 8c68e4a: * src/buffer.c (Fmove_overlay): Don't call Fdelete_overlay,
Stefan Monnier <=