Browse Source

org-element: Fix cache bug

* lisp/org-element.el (org-element-context): First initialize cache
  before retrieving data from it.
Nicolas Goaziou 11 years ago
parent
commit
ef207f4424
1 changed files with 4 additions and 2 deletions
  1. 4 2
      lisp/org-element.el

+ 4 - 2
lisp/org-element.el

@@ -5782,8 +5782,10 @@ Providing it allows for quicker computation."
        (let* ((restriction (org-element-restriction type))
        (let* ((restriction (org-element-restriction type))
 	      (parent element)
 	      (parent element)
 	      (candidates 'initial)
 	      (candidates 'initial)
-	      (cache (and (org-element--cache-active-p)
-			  (gethash element org-element--cache-objects)))
+	      (cache (cond ((not (org-element--cache-active-p)) nil)
+			   (org-element--cache-objects
+			    (gethash element org-element--cache-objects))
+			   (t (org-element-cache-reset) nil)))
 	      objects-data next)
 	      objects-data next)
 	 (prog1
 	 (prog1
 	     (catch 'exit
 	     (catch 'exit