summaryrefslogtreecommitdiff
path: root/lisp/allout-widgets.el
diff options
context:
space:
mode:
authorKen Manheimer <ken.manheimer@gmail.com>2011-03-29 14:26:01 -0400
committerKen Manheimer <ken.manheimer@gmail.com>2011-03-29 14:26:01 -0400
commitd806ab682a8e914345db3f2eede292f85745c98c (patch)
tree1c92f7e126958fe72a6aca21e966a0e5a1bc006a /lisp/allout-widgets.el
parent94eab1c84d9862cb56db2f610362e33107d75774 (diff)
downloademacs-d806ab682a8e914345db3f2eede292f85745c98c.tar.gz
* allout.el (allout-hide-by-annotation, allout-flag-region): Reduce
possibility of overlay leakage by making them volatile. * allout-widgets.el (allout-widgets-tally): Define as nil so the hash is not shared between buffers. Mode initialization is responsible for giving it a useful starting value. (allout-item-span): Reduce possibility of overlay leakage by making them volatile. (allout-widgets-count-buttons-in-region): Add diagnostic function for tracking down overlay leaks.
Diffstat (limited to 'lisp/allout-widgets.el')
-rw-r--r--lisp/allout-widgets.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/allout-widgets.el b/lisp/allout-widgets.el
index 47f181ab76b..ae4265bda1f 100644
--- a/lisp/allout-widgets.el
+++ b/lisp/allout-widgets.el
@@ -238,7 +238,7 @@ buffer, and tracking increases as new widgets are added and
decreases as obsolete widgets are garbage collected."
:type 'boolean
:group 'allout-widgets-developer)
-(defvar allout-widgets-tally (make-hash-table :test 'eq :weakness 'key)
+(defvar allout-widgets-tally nil
"Hash-table of existing allout widgets, for debugging.
Table is maintained iff `allout-widgets-maintain-tally' is non-nil.
@@ -2100,6 +2100,7 @@ previously established or is not moved."
(cond ((not overlay) (when start
(setq overlay (make-overlay start end nil t nil))
(overlay-put overlay 'button item-widget)
+ (overlay-put overlay 'evaporate t)
(widget-put item-widget :span-overlay overlay)
t))
;; report:
@@ -2343,6 +2344,19 @@ The elements of LIST are not copied, just the list structure itself."
(while (consp list) (push (pop list) res))
(prog1 (nreverse res) (setcdr res list)))
(car list)))
+;;;_ . allout-widgets-count-buttons-in-region (start end)
+(defun allout-widgets-count-buttons-in-region (start end)
+ "Debugging/diagnostic tool - count overlays with 'button' property in region."
+ (interactive "r")
+ (setq start (or start (point-min))
+ end (or end (point-max)))
+ (if (> start end) (let ((interim start)) (setq start end end interim)))
+ (let ((button-overlays (delq nil
+ (mapcar (function (lambda (o)
+ (if (overlay-get o 'button)
+ o)))
+ (overlays-in start end)))))
+ (length button-overlays)))
;;;_ : Run unit tests:
(defun allout-widgets-run-unit-tests ()