From 3170f05da22609386589b8e7ad1e88f7e3743745 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 9 Aug 2009 13:48:09 +0000 Subject: [PATCH] correctly handle multiple registrations of the same snipclass name svn: r15692 --- collects/mred/private/wxme/snip.ss | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/collects/mred/private/wxme/snip.ss b/collects/mred/private/wxme/snip.ss index f8188ff802..037ba3ee41 100644 --- a/collects/mred/private/wxme/snip.ss +++ b/collects/mred/private/wxme/snip.ss @@ -1238,11 +1238,15 @@ (def/public (add [snip-class% c]) (let ([name (send c get-classname)]) - (hash-set! ht name c) - (let ([n (hash-count pos-ht)]) - (hash-set! pos-ht c n) - (hash-set! rev-pos-ht n c)))) - + (let ([old (hash-ref ht name #f)]) + (hash-set! ht name c) + (let ([n (if old + (hash-ref pos-ht old) + (hash-count pos-ht))]) + (when old (hash-remove! pos-ht old)) + (hash-set! pos-ht c n) + (hash-set! rev-pos-ht n c))))) + (def/public (number) (hash-count ht)) (def/public (nth [exact-nonnegative-integer? n]) (hash-ref rev-pos-ht n #f)))