diff options
author | Daniel Kochmański <daniel@turtleware.eu> | 2024-07-19 12:12:40 +0200 |
---|---|---|
committer | Daniel Kochmański <daniel@turtleware.eu> | 2024-09-17 09:02:28 +0200 |
commit | 22010737a082cf954b760862d8e66fe3c4b8f489 (patch) | |
tree | ae569ac62a895a0acd9550ac12ad096914b832c3 | |
parent | 4ae5e3b71d56afdb0ce910b4d34e01497ba8aa9c (diff) |
core: don't declare WITH-SHEET-MEDIUM continuation as dynamic-extent
Declaring the dynamic function as having a dynamic extent may lead to hard to
understand and debug errors, for example:
(flet ((foo ()
(with-sheet-medium (medium sheet)
(do-something medium))))
(let ((*x* 420)) (foo)))
The code above had undefined behavior, because the continuation
capturing (do-something medium) was nvoked outside of its dynamic extent.
Also a few cosmetic fixes (indent and printing).
-rw-r--r-- | Core/extended-output/output-record.lisp | 18 | ||||
-rw-r--r-- | Core/geometry/transforms.lisp | 2 | ||||
-rw-r--r-- | Core/windowing/output.lisp | 14 |
3 files changed, 16 insertions, 18 deletions
diff --git a/Core/extended-output/output-record.lisp b/Core/extended-output/output-record.lisp index 2fa58ec4..9d4562ae 100644 --- a/Core/extended-output/output-record.lisp +++ b/Core/extended-output/output-record.lisp @@ -1542,15 +1542,15 @@ the associated sheet can be determined." &optional region (x-offset 0) (y-offset 0)) (declare (ignore region)) (with-identity-transformation (stream) - (with-translation (stream x-offset y-offset) - (let ((rect (copy-bounding-rectangle record)) - (ink1 (compose-in +blue+ (make-opacity .1))) - (ink2 +black+) - (ink3 (compose-in +black+ (make-opacity .5)))) - (draw-design stream rect :filled t :ink ink1) - (draw-design stream rect :filled nil :ink ink2 :line-thickness .5) - (with-bounding-rectangle* (:center-x cx :center-y cy) rect - (draw-point* stream cx cy :line-thickness 10 :ink ink3)))))) + (with-translation (stream x-offset y-offset) + (let ((rect (copy-bounding-rectangle record)) + (ink1 (compose-in +blue+ (make-opacity .1))) + (ink2 +black+) + (ink3 (compose-in +black+ (make-opacity .5)))) + (draw-design stream rect :filled t :ink ink1) + (draw-design stream rect :filled nil :ink ink2 :line-thickness .5) + (with-bounding-rectangle* (:center-x cx :center-y cy) rect + (draw-point* stream cx cy :line-thickness 10 :ink ink3)))))) (defrecord-predicate draw-text-output-record (string start end diff --git a/Core/geometry/transforms.lisp b/Core/geometry/transforms.lisp index 7c97b5aa..6f6234a9 100644 --- a/Core/geometry/transforms.lisp +++ b/Core/geometry/transforms.lisp @@ -123,7 +123,7 @@ transformation protocol.")) (defmethod print-object ((transformation standard-hairy-transformation) sink) (maybe-print-readably (transformation sink) (print-unreadable-object (transformation sink :identity nil :type t) - (apply #'format sink "~S ~S ~S ~S ~S ~S" + (apply #'format sink "~,2f ~,2f ~,2f ~,2f ~,2f ~,2f" (multiple-value-list (get-transformation transformation)))))) (defmethod print-object ((transformation standard-transformation) sink) diff --git a/Core/windowing/output.lisp b/Core/windowing/output.lisp index 7b3761b9..f739cd10 100644 --- a/Core/windowing/output.lisp +++ b/Core/windowing/output.lisp @@ -86,10 +86,9 @@ (defmacro with-sheet-medium ((medium sheet) &body body) (check-type medium symbol) (let ((fn (gensym))) - `(labels ((,fn (,medium) - ,(declare-ignorable-form* medium) - ,@body)) - (declare (dynamic-extent (function ,fn))) + `(flet ((,fn (,medium) + ,(declare-ignorable-form* medium) + ,@body)) (invoke-with-sheet-medium (function ,fn) ,sheet)))) (defmethod invoke-with-sheet-medium @@ -119,10 +118,9 @@ (let ((fn (gensym)) (medium-var (if (symbolp medium) medium (gensym)))) (once-only (sheet) - `(labels ((,fn (,medium-var) - ,(declare-ignorable-form* medium-var) - ,@body)) - (declare (dynamic-extent (function ,fn))) + `(flet ((,fn (,medium-var) + ,(declare-ignorable-form* medium-var) + ,@body)) (if-let ((,medium-var (sheet-medium ,sheet))) (,fn ,medium-var) (invoke-with-sheet-medium-bound (function ,fn) ,medium ,sheet)))))) |