racket/draw: pens and brushes from lists should be immutable
Closes PR 12732
This commit is contained in:
parent
a8ca75b773
commit
5e4b9e3aca
|
@ -212,6 +212,7 @@
|
|||
(ephemeron-value e))
|
||||
(let* ([f (make-object brush% col s)]
|
||||
[e (make-ephemeron key f)])
|
||||
(send f set-immutable)
|
||||
(send f s-set-key key)
|
||||
(hash-set! brushes key e)
|
||||
f)))
|
||||
|
|
|
@ -164,6 +164,7 @@
|
|||
(ephemeron-value e))
|
||||
(let* ([f (make-object pen% col w s c j)]
|
||||
[e (make-ephemeron key f)])
|
||||
(send f set-immutable)
|
||||
(send f s-set-key key)
|
||||
(hash-set! pens key e)
|
||||
f)))
|
||||
|
|
|
@ -507,4 +507,17 @@
|
|||
|
||||
;; ----------------------------------------
|
||||
|
||||
(define (check-immutable v)
|
||||
(test 'immutable 'immutable
|
||||
(with-handlers ([exn:fail? (lambda (x)
|
||||
(if (regexp-match #rx"immutable" (exn-message x))
|
||||
'immutable
|
||||
x))])
|
||||
(send v set-color "red"))))
|
||||
|
||||
(check-immutable (send the-brush-list find-or-create-brush "white" 'solid))
|
||||
(check-immutable (send the-pen-list find-or-create-pen "white" 1 'solid))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
Loading…
Reference in New Issue
Block a user