@@ -119,7 +119,7 @@ async def update(self, engine, node, references, *, default_size=(512, 512), **k
119119 await result
120120
121121 def similar_to (self , node ):
122- return node .tags == self .tags
122+ return node .tags == self .tags and node . get ( 'id' , 1 , str ) == self . node_id
123123
124124 def create (self , engine , node , resized , ** kwargs ):
125125 pass
@@ -138,13 +138,17 @@ async def descend(self, engine, node, references, **kwargs):
138138 for i , scene_node in enumerate (existing ):
139139 if type (scene_node ) is cls and scene_node .similar_to (child ):
140140 scene_node = existing .pop (i )
141+ await scene_node .update (engine , child , references , ** kwargs )
141142 break
142143 else :
143144 scene_node = cls (self .glctx )
144- await scene_node .update (engine , child , references , ** kwargs )
145+ await scene_node .update (engine , child , references , ** kwargs )
146+ logger .trace ("New window node: {}" , scene_node .name )
145147 updated .append (scene_node )
146148 while existing :
147- await existing .pop ().destroy ()
149+ scene_node = existing .pop ()
150+ logger .trace ("Destroy window node: {}" , scene_node .name )
151+ await scene_node .destroy ()
148152 self .children = updated
149153
150154 def render (self , node , references , ** kwargs ):
@@ -156,6 +160,9 @@ def parent_finished(self):
156160 def handle_node (self , engine , node , ** kwargs ):
157161 return False
158162
163+ def __repr__ (self ):
164+ return f"<{ self .name } { ' id=' + self .node_id if self .node_id else '' } >"
165+
159166
160167class Reference (WindowNode ):
161168 def __init__ (self , glctx ):
@@ -174,8 +181,8 @@ def array(self):
174181 return self ._reference .array if self ._reference is not None else None
175182
176183 async def update (self , engine , node , references , ** kwargs ):
177- node_id = node .get ('id' , 1 , str )
178- self ._reference = references .get (node_id ) if node_id else None
184+ self . node_id = node .get ('id' , 1 , str )
185+ self ._reference = references .get (self . node_id ) if self . node_id else None
179186
180187
181188class ProgramNode (WindowNode ):
0 commit comments