@@ -138,7 +138,7 @@ impl<G: GlobalEventHandler> Runtime<G> {
138138
139139 loop {
140140 frame. tick ( backend) ?;
141- if frame. stop {
141+ if frame. layout_ctx . stop_runtime {
142142 return Err ( Error :: Stop ) ;
143143 }
144144
@@ -191,7 +191,6 @@ impl<G: GlobalEventHandler> Runtime<G> {
191191
192192 dt : & mut self . dt ,
193193 needs_layout : true ,
194- stop : false ,
195194
196195 global_event_handler : & self . global_event_handler ,
197196 tabindex : None ,
@@ -231,7 +230,6 @@ pub struct Frame<'rt, 'bp, G> {
231230 message_receiver : & ' rt flume:: Receiver < ViewMessage > ,
232231 dt : & ' rt mut Instant ,
233232 needs_layout : bool ,
234- stop : bool ,
235233 global_event_handler : & ' rt G ,
236234 pub tabindex : Option < Index > ,
237235}
@@ -280,7 +278,7 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
280278
281279 let Some ( event) = self . handle_global_event ( event) else { return } ;
282280 if let Event :: Stop = event {
283- self . stop = true ;
281+ self . layout_ctx . stop_runtime = true ;
284282 return ;
285283 }
286284
@@ -327,18 +325,21 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
327325 puffin:: GlobalProfiler :: lock ( ) . new_frame ( ) ;
328326
329327 let now = Instant :: now ( ) ;
330- self . cycle ( backend) ?;
331328 self . init_new_components ( ) ;
332- self . tick_components ( self . dt . elapsed ( ) ) ;
333329 let elapsed = self . handle_messages ( now) ;
334330 self . poll_events ( elapsed, now, backend) ;
335331 self . drain_deferred_commands ( ) ;
336332 self . drain_assoc_events ( ) ;
333+
334+ // TODO:
335+ // this secondary call is here to deal with changes causing changes
336+ // which happens when values are removed or inserted and indices needs updating
337337 self . apply_changes ( ) ?;
338- // TODO: this secondary call is here to deal with changes causing changes
339- // which happens when values are removed or inserted and indices needs updating
340338 self . apply_changes ( ) ?;
341339
340+ self . tick_components ( self . dt . elapsed ( ) ) ;
341+ self . cycle ( backend) ?;
342+
342343 * self . dt = Instant :: now ( ) ;
343344
344345 match self . layout_ctx . stop_runtime {
@@ -405,6 +406,11 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
405406 backend. resize ( size, self . layout_ctx . glyph_map ) ;
406407 }
407408
409+ if let Event :: Stop = event {
410+ self . layout_ctx . stop_runtime = true ;
411+ break ;
412+ }
413+
408414 self . event ( event) ;
409415
410416 // Make sure event handling isn't holding up the rest of the event loop.
@@ -491,8 +497,8 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
491497 self . with_component ( widget_id, state_id, |comp, children, ctx| {
492498 comp. dyn_component . any_message ( children, ctx, msg) ;
493499 } ) ;
500+ break ;
494501 }
495- break ;
496502 }
497503 }
498504 }
@@ -564,16 +570,6 @@ impl<'rt, 'bp, G: GlobalEventHandler> Frame<'rt, 'bp, G> {
564570 let widget_id = value_id. key ( ) ;
565571
566572 if let Some ( widget) = tree. get_mut ( widget_id) {
567- let kind = & widget. kind ;
568- match kind {
569- WidgetKind :: Element ( _element) => { }
570- WidgetKind :: For ( _forloop) => { }
571- WidgetKind :: Iteration ( _) => { }
572- _ => ( ) , // WidgetKind::ControlFlow(control_flow) => todo!(),
573- // WidgetKind::ControlFlowContainer(_) => todo!(),
574- // WidgetKind::Component(component) => todo!(),
575- // WidgetKind::Slot => todo!(),
576- }
577573 if let WidgetKind :: Element ( element) = & mut widget. kind {
578574 element. invalidate_cache ( ) ;
579575 }
0 commit comments