Skip to content

Commit

Permalink
measure_text_system text query fix (bevyengine#8466)
Browse files Browse the repository at this point in the history
# Objective

The first query of `measure_text_system`'s `text_queries` `ParamSet`
queries for all changed `Text` meaning that non-UI `Text` entities could
be added to its queue.

## Solution

Add a `With<Node>` query filter.

---

## Changelog
changes:
* Added a `With<Node>` query filter to first query of
`measure_text_system`'s `text_queries` `ParamSet` to ensure that only UI
node entities are added to its local queue.
* Fixed comment (text is not computed on changes to style).
  • Loading branch information
ickshonpe committed Apr 22, 2023
1 parent 9920b64 commit 0c14fef
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_ui/src/widget/text.rs
Expand Up @@ -68,7 +68,7 @@ pub fn measure_text_system(
ui_scale: Res<UiScale>,
mut text_pipeline: ResMut<TextPipeline>,
mut text_queries: ParamSet<(
Query<Entity, Changed<Text>>,
Query<Entity, (Changed<Text>, With<Node>)>,
Query<Entity, (With<Text>, With<Node>)>,
Query<(&Text, &mut CalculatedSize)>,
)>,
Expand All @@ -82,7 +82,7 @@ pub fn measure_text_system(

#[allow(clippy::float_cmp)]
if *last_scale_factor == scale_factor {
// Adds all entities where the text or the style has changed to the local queue
// Adds all entities where the text has changed to the local queue
for entity in text_queries.p0().iter() {
if !queued_text.contains(&entity) {
queued_text.push(entity);
Expand Down

0 comments on commit 0c14fef

Please sign in to comment.