fix `image-snip%' unmarshaling with filename

Merge to 5.1
(cherry picked from commit c2c6c79a15)
This commit is contained in:
Matthew Flatt 2011-02-02 19:00:27 -07:00 committed by Eli Barzilay
parent 9b9dc8c2f8
commit 9215e3c401
2 changed files with 20 additions and 2 deletions

View File

@ -787,8 +787,7 @@
(def/override (read [editor-stream-in% f])
(let ([scl (get-the-snip-class-list)]
[can-inline? ((send f do-reading-version this) . > . 1)])
(let ([filename (let ([s (send f get-bytes #f)])
(subbytes s 0 (max 0 (sub1 (bytes-length s)))))])
(let ([filename (send f get-bytes #f)])
(let-boxes ([type 0]
[w 0.0]
[h 0.0]

View File

@ -1347,4 +1347,23 @@
;; ----------------------------------------
(let ()
(define (mk) (make-object image-snip% (collection-file-path "b-run.png" "icons") 'unknown #f #f))
(define is (mk))
(define copy-is
(let ()
(define sp (open-output-string))
(define t (new text%))
(send t insert (mk))
(send t save-port sp)
(define t2 (new text%))
(send t2 insert-port (open-input-string (get-output-string sp)))
(send t2 find-first-snip)))
(expect (send (mk) get-filename)
(send copy-is get-filename)))
;; ----------------------------------------
(done)