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

Re: with-cursor



At  1:54 PM 11/18/93 -0500, Doug Currie, Flavors Technology, Inc. wrote:
>>(with-cursor *watch-cursor* body)
>>macro-expands to 
>>(let ((*cursorhook* *watch-cursor*)) (update-cursor) body)
>>not something like:
>>(progn (let ((*cursorhook* *watch-cursor*)) 
>>         (update-cursor) body)
>>       (update-cursor))
>>
>>My main question is how does this work ever? What triggers resetting the
>>cursor in the cases where it is reset?
>
>from MCL sources "level-1;events.lisp"
>
>; Default method justs updates cursor
>(defmethod window-null-event-handler (w)
>  (declare (ignore w))
>  (update-cursor))
>
>So, window-null-event-handler does an (update-cursor) and the cursor is
>_eventually_ restored. I have wondered why the macro is this way also; we
>have a problem where if a gc occurs during a long operation, the gc's
>with-cursor does not appear to restore our watch cursor since we're not
>processing events.

I agree that with-cursor should explicitly restore the cursor on exit.
Patch included below. Fixing this for the garbage collector is
harder as it requires a patch to the kernel. This patch will not fix
that behavior.

--------------------------------------------------------------------

; with-cursor-patch.lisp
;
; with-cursor now explicitly restores the cursor on exit
; instead of waiting for event processing.

(in-package :ccl)

(let ((*warn-if-redefine* nil)
      (*warn-if-redefine-kernel* nil))

(defmacro with-cursor (cursor &body body)
  `(unwind-protect
     (let ((*cursorhook* ,cursor))
       (update-cursor)
       ,@body)
     (update-cursor)))

)