correctly handle multiple registrations of the same snipclass name
svn: r15692
This commit is contained in:
parent
a090aa60a9
commit
3170f05da2
|
@ -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)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user