Fixed some resource leaks in the UI

slava 2006-03-21 07:40:16 +00:00
parent b87d1b1973
commit c94ba8665b
4 changed files with 16 additions and 10 deletions

View File

@ -134,10 +134,10 @@ H{ } clone views set-global
[ 2drop 1 ] [ 2drop 1 ]
} }
{ "init" "id" { "id" "SEL" } { "initWithFrame:pixelFormat:" "id" { "id" "SEL" "NSRect" "id" }
[ [
drop rot drop
SUPER-> [init] SUPER-> [initWithFrame:pixelFormat:]
dup "updateFactorGadgetSize:" add-resize-observer dup "updateFactorGadgetSize:" add-resize-observer
] ]
} }
@ -165,7 +165,8 @@ H{ } clone views set-global
IN: gadgets IN: gadgets
: repaint-handle ( handle -- ) 1 [setNeedsDisplay:] ; : repaint-handle ( handle -- )
1 [setNeedsDisplay:] ;
: in-window ( gadget status dim title -- ) : in-window ( gadget status dim title -- )
>r <world> r> <FactorWindow> drop ; >r <world> r> <FactorWindow> drop ;

View File

@ -69,12 +69,14 @@ V{ } clone hand-buttons set-global
[ lose-focus ] swap each-gesture [ lose-focus ] swap each-gesture
[ gain-focus ] swap each-gesture ; [ gain-focus ] swap each-gesture ;
: request-focus ( gadget -- ) : request-focus* ( gadget world -- )
dup focusable-child swap find-world
dup focused-ancestors >r dup focused-ancestors >r
[ set-world-focus ] keep [ set-world-focus ] keep
focused-ancestors r> focus-gestures ; focused-ancestors r> focus-gestures ;
: request-focus ( gadget -- )
dup focusable-child swap find-world request-focus* ;
: drag-loc ( -- loc ) : drag-loc ( -- loc )
hand-loc get-global hand-click-loc get-global v- ; hand-loc get-global hand-click-loc get-global v- ;

View File

@ -59,7 +59,7 @@ SYMBOL: stack-bar
<input-pane> dup pane set-global <scroller> ; <input-pane> dup pane set-global <scroller> ;
: <listener> ( -- gadget status ) : <listener> ( -- gadget status )
<frame> dup solid-interior <frame>
<input-pane> dup pane set-global <scroller> <input-pane> dup pane set-global <scroller>
over @center frame-add over @center frame-add
<bottom-bar> >r over @bottom frame-add r> ; <bottom-bar> >r over @bottom frame-add r> ;

View File

@ -1,7 +1,7 @@
! Copyright (C) 2005, 2006 Slava Pestov. ! Copyright (C) 2005, 2006 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: gadgets IN: gadgets
USING: freetype gadgets-layouts generic hashtables kernel USING: errors freetype gadgets-layouts generic hashtables kernel
namespaces opengl sequences ; namespaces opengl sequences ;
! The world gadget is the top level gadget that all (visible) ! The world gadget is the top level gadget that all (visible)
@ -19,7 +19,10 @@ TUPLE: world glass status focus fonts handle ;
world-fonts [ drop V{ } clone ] cache ; world-fonts [ drop V{ } clone ] cache ;
: close-world ( world -- ) : close-world ( world -- )
dup remove-notify dup free-fonts f swap set-world-handle ; f over request-focus*
dup remove-notify
dup free-fonts
f swap set-world-handle ;
C: world ( gadget status dim -- world ) C: world ( gadget status dim -- world )
<stack> over set-delegate <stack> over set-delegate
@ -49,7 +52,7 @@ M: gadget find-world gadget-parent find-world ;
M: world find-world ; M: world find-world ;
: repaint ( gadget -- ) : repaint ( gadget -- )
find-world [ world-handle repaint-handle ] when* ; find-world [ world-handle [ repaint-handle ] when* ] when* ;
: focused-ancestors ( world -- seq ) : focused-ancestors ( world -- seq )
world-focus parents reverse-slice ; world-focus parents reverse-slice ;