Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in bevy_ui when building without bevy_text #14430

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

BD103
Copy link
Member

@BD103 BD103 commented Jul 22, 2024

Objective

  • bevy_ui does not build without the bevy_text feature due to improper feature gating.
    • Specifically, MeasureArgs<'a> had an unused lifetime 'a without bevy_text enabled. This is because it stores a reference to a cosmic_text::FontSystem.
    • This was caught by flag-frenzy in this run.

Solution

  • Add a PhantomData to MeasureArgs<'a> in order to maintain its lifetime argument.
    • I also named it font_system, after the feature-gated argument that actually needs a lifetime, for usability. Please comment if you have a better solution!
  • Move some unused imports to be behind the bevy_text feature gate.

Testing

# Fails on main.
cargo check -p bevy_ui --no-default-features
# Succeeds on main.
cargo check -p bevy_ui --no-default-features -F bevy_text

Migration Guide

This is not a breaking change for users migrating from 0.14, since MeasureArgs did not exist then.

When the bevy_text feature is disabled for bevy_ui, the type of the MeasureArgs::font_system field is now a PhantomData instead of being removed entirely. This is in order to keep the lifetime parameter, even though it is unused without text being enabled.

@BD103 BD103 added C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy A-UI Graphical user interfaces, styles, layouts, and widgets P-Regression Functionality that used to work but no longer does. Add a test for this! S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 22, 2024
@alice-i-cecile alice-i-cecile added this to the 0.15 milestone Jul 22, 2024
crates/bevy_ui/src/measurement.rs Outdated Show resolved Hide resolved
@BD103 BD103 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 22, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jul 22, 2024
Merged via the queue into bevyengine:main with commit cd49715 Jul 22, 2024
28 checks passed
@BD103 BD103 deleted the fix-ui-without-text branch July 22, 2024 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy P-Regression Functionality that used to work but no longer does. Add a test for this! S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants