From 0cf3000ee0652aaa57d448b1550036aaed459697 Mon Sep 17 00:00:00 2001 From: ickshonpe Date: Fri, 21 Apr 2023 15:23:46 +0100 Subject: [PATCH] Fix the double leaf node updates in `flex_node_system` (#8264) # Objective If a UI node has a changed `CalculatedSize` component and either the UI does a full update or the node also has a changed `Style` component, the node's corresponding Taffy node will be updated twice by `flex_node_system`. ## Solution Add a `Without` query filter so that the two changed node queries in `flex_node_system` are mutually exclusive and move the `CalculatedSize` node updater into the else block of the full-update if conditional. --- crates/bevy_ui/src/layout/mod.rs | 45 +++++++++++++++----------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/crates/bevy_ui/src/layout/mod.rs b/crates/bevy_ui/src/layout/mod.rs index 077f8a898706a..8c808be06dcaf 100644 --- a/crates/bevy_ui/src/layout/mod.rs +++ b/crates/bevy_ui/src/layout/mod.rs @@ -5,7 +5,7 @@ use bevy_ecs::{ change_detection::DetectChanges, entity::Entity, event::EventReader, - query::{Changed, ReadOnlyWorldQuery, With, Without}, + query::{Changed, Or, With, Without}, removal_detection::RemovedComponents, system::{Query, Res, ResMut, Resource}, }; @@ -244,11 +244,14 @@ pub fn ui_layout_system( mut resize_events: EventReader, mut ui_surface: ResMut, root_node_query: Query, Without)>, - node_query: Query<(Entity, &Style, Option<&CalculatedSize>), (With, Changed