]> gitweb.factorcode.org Git - factor.git/commitdiff
fix bugs and also destroy textures whose refcounts are 0 on ungraft*
authorMatthew Willis <matthew.willis@mac.com>
Mon, 2 Jun 2008 23:31:32 +0000 (16:31 -0700)
committerMatthew Willis <matthew.willis@mac.com>
Mon, 2 Jun 2008 23:31:32 +0000 (16:31 -0700)
extra/pango/cairo/gadgets/gadgets.factor

index fb021e9320e8783b4a148c6ea496055d8a32041e..4c46b4e5015fb36a472efa4cd67d80cc90b4bc70 100644 (file)
@@ -44,15 +44,21 @@ M: pango-gadget dim>> ( gadget -- dim )
 
 M: pango-gadget graft* ( gadget -- ) [ 1+ ] refcount-change ;
 
-M: pango-gadget ungraft* ( gadget -- ) [ 1- ] refcount-change ;
+: release-texture ( gadget -- )
+    cache-key textures get delete-at* [ delete-texture ] [ drop ] if ;
+
+M: pango-gadget ungraft* ( gadget -- )
+    dup [ 1- ] refcount-change
+    dup cache-key refcounts get at
+    zero? [ release-texture ] [ drop ] if ;
 
 M: pango-gadget render* ( gadget -- ) 
-    [ gen-texture ] [ cache-key textures get set-at ]
-    [ call-next-method ] tri ;
+    [ gen-texture ] [ cache-key textures get set-at ] bi
+    call-next-method ;
 
 M: pango-gadget tex>> ( gadget -- texture )
     dup cache-key textures get at 
-    [ ] [ render* tex>> ] ?if ;
+    [ nip ] [ dup render* tex>> ] if* ;
 
 USE: ui.gadgets.panes
 : hello "Sans 50" "hello" <pango-gadget> gadget. ;