Browse files

In hindsight, it doesn't really make sense to store the meta values as

weak refs. I don't know what I was thinking.
  • Loading branch information...
daveray committed Apr 14, 2012
1 parent b1e43ce commit e3ad03d283275d758e36d134728e9bb1ec4785c9
Showing with 9 additions and 10 deletions.
  1. +7 −8 src/seesaw/meta.clj
  2. +2 −2 test/seesaw/test/meta.clj
@@ -2,16 +2,15 @@
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (
-; which can be found in the file epl-v10.html at the root of this
+; which can be found in the file epl-v10.html at the root of this
; distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns ^{:doc "Functions for associating metadata with frames and widgets, etc."
:author "Dave Ray"}
- seesaw.meta
- (:import [java.lang.ref WeakReference]))
+ seesaw.meta)
(defprotocol Meta
(put-meta! [this key value])
@@ -21,15 +20,15 @@
(extend-protocol Meta
- (put-meta! [this key value]
+ (put-meta! [this key value]
(if-let [this-map (.get ^java.util.Map meta-map this)]
- (.put ^java.util.Map this-map key (WeakReference. value))
- (.put ^java.util.Map meta-map this (doto (java.util.HashMap.) (.put key (WeakReference. value)))))
+ (.put ^java.util.Map this-map key value)
+ (.put ^java.util.Map meta-map this (doto (java.util.HashMap.)
+ (.put key value))))
(get-meta [this key]
(when-let [this-map (.get ^java.util.Map meta-map this)]
- (when-let [^WeakReference weak-ref (.get ^java.util.Map this-map key)]
- (.get weak-ref))))
+ (.get ^java.util.Map this-map key)))
(put-meta! [this key value] (doto this (.putClientProperty key value)))
@@ -41,7 +41,7 @@
(testing "when called on Object"
(it "stores metadata somewhere, retrievable by get-meta"
(let [f (javax.swing.JFrame.)
- result (put-meta! f :some-key 100)]
+ result (put-meta! f :some-key 10000)]
(expect (= f result))
- (expect (= 100 (get-meta f :some-key)))))))
+ (expect (= 10000 (get-meta f :some-key)))))))

0 comments on commit e3ad03d

Please sign in to comment.