@@ -815,7 +815,7 @@ fn update_widgets(
815815 for child in
816816 tree. down_iter_at ( * changed_entity, false )
817817 {
818- trace ! (
818+ info ! (
819819 "Removing AvsB children {}::{}" ,
820820 entity_ref
821821 . get:: <WidgetName >( )
@@ -827,34 +827,42 @@ fn update_widgets(
827827 if let Ok ( order_tree) =
828828 order_tree. try_read ( )
829829 {
830- ' back_up: for sibling in order_tree
831- . child_iter (
832- order_tree
833- . parent ( * changed_entity)
834- . unwrap ( ) ,
835- )
836- {
837- for child in
838- tree. down_iter_at ( sibling, true )
830+ if let Some ( order_tree_parent) = order_tree
831+ . parent ( * changed_entity) {
832+ ' back_up: for sibling in order_tree
833+ . child_iter ( order_tree_parent)
839834 {
840- if let Some ( entity_ref) =
841- world. get_entity ( child. 0 )
842- {
843- if let Some ( children) =
844- entity_ref
845- . get :: < KChildren > ( )
835+ dbg ! ( sibling, changed_entity) ;
836+ if sibling == * changed_entity {
837+ continue ' back_up;
838+ }
839+ for child in
840+ tree. down_iter_at ( sibling, true )
841+ {
842+ // Ignore self again.
843+ dbg ! ( child) ;
844+ if child == * parent {
845+ continue ;
846+ }
847+ if let Some ( entity_ref) =
848+ world. get_entity ( child. 0 )
846849 {
847- if children
848- . contains_entity (
849- changed_entity
850- . 0 ,
851- )
850+ if let Some ( children) =
851+ entity_ref
852+ . get :: < KChildren > ( )
852853 {
853- trace ! ( "Caught an entity that was marked as deleted but wasn't! {:?}" , changed_entity. 0 ) ;
854- // Don't despawn changed entity because it exists as a child passed via props
855- should_delete =
856- false ;
857- break ' back_up;
854+ if children
855+ . contains_entity (
856+ changed_entity
857+ . 0 ,
858+ )
859+ {
860+ info ! ( "Caught an entity that was marked as deleted but wasn't! {:?} in {:?}" , changed_entity. 0 , child. 0 ) ;
861+ // Don't despawn changed entity because it exists as a child passed via props
862+ should_delete =
863+ false ;
864+ break ' back_up;
865+ }
858866 }
859867 }
860868 }
@@ -1005,7 +1013,7 @@ fn update_widgets(
10051013 entity_mut. get:: <WidgetName >( ) ,
10061014 parent. index( ) ,
10071015 ) ;
1008- entity_mut. remove_parent ( ) ;
1016+ entity_mut. remove :: < Parent > ( ) ;
10091017 entity_mut. remove :: < bevy:: prelude:: Children > ( ) ;
10101018 entity_mut. despawn ( ) ;
10111019
0 commit comments