From d9fd94f6080bdf4b78e1d293a4920f106d78ece3 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 4 May 2015 18:01:47 -0500 Subject: [PATCH] fix handling of snip%s that don't have a snipclass --- gui-lib/framework/private/text.rkt | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/gui-lib/framework/private/text.rkt b/gui-lib/framework/private/text.rkt index c0a07860..9ebba035 100644 --- a/gui-lib/framework/private/text.rkt +++ b/gui-lib/framework/private/text.rkt @@ -2232,14 +2232,20 @@ (struct snip-special (snip name bytes)) (define (make-snip-special snip) - (define base (new editor-stream-out-bytes-base%)) - (define stream (make-object editor-stream-out% base)) - (send snip write stream) - (snip-special snip - (send (send snip get-snipclass) get-classname) - (send base get-bytes))) + (define the-snipclass (send snip get-snipclass)) + (cond + [the-snipclass + (define base (new editor-stream-out-bytes-base%)) + (define stream (make-object editor-stream-out% base)) + (send snip write stream) + (snip-special snip + (send the-snipclass get-classname) + (send base get-bytes))] + [else + (snip-special snip #f #f)])) (define (snip-special->snip snip-special) - (define snipclass (send (get-the-snip-class-list) find (snip-special-name snip-special))) + (define the-name (snip-special-name snip-special)) + (define snipclass (and the-name (send (get-the-snip-class-list) find the-name))) (cond [snipclass (define base (make-object editor-stream-in-bytes-base%