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

Avoid FlowContainer crash with TextureRect using EXPAND_FIT_* expand modes #94286

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

aaronp64
Copy link
Contributor

When a FlowContainer had a TextureRect child using any of the EXPAND_FIT_* expand modes, it could crash when changing the FlowContainer's minimum size, or that of its children. This was due to the TextureRect resizing in FlowContainer::_resort, updating its minimum size, and triggering another _resort. If the TextureRect's minimum size changed in a way that caused any of the FlowContainer's children to be put on a different line, it could repeatedly cause _resort to be called again, moving the children back and forth between the old and new lines.

This change is for FlowContainer::_resort to give a warning for TextureRects with EXPAND_FIT_* expand modes when multiple lines are used, and just keep the TextureRect size the same in that case. This is similar to the check added to AspectRatioContainer in #73396, but attempting to still support it in FlowContainer when possible. In the case where the TextureRect is forced to stay the same size, there may be some overlap between the FlowContainer's children, but should no longer crash.

Fixes #93767

@aaronp64 aaronp64 requested a review from a team as a code owner July 12, 2024 21:13
@KoBeWi KoBeWi added this to the 4.3 milestone Jul 12, 2024
…modes

When a FlowContainer had a TextureRect child using any of the EXPAND_FIT_* expand modes, it could crash when changing the FlowContainer's minimum size, or that of its children.  This was due to the TextureRect resizing in FlowContainer::_resort, updating its minimum size, and triggering another _resort.  If the TextureRect's minimum size changed in a way that caused any of the FlowContainer's children to be put on a different line, it could repeatedly cause _resort to be called again, moving the children back and forth between the old and new lines.

This change is for FlowContainer::_resort to give a warning for TextureRects with EXPAND_FIT_* expand modes when multiple lines are used, and just keep the TextureRect size the same in that case.  This is similar to the check added to AspectRatioContainer in godotengine#73396, but attempting to still support it in FlowContainer when possible.  In the case where the TextureRect is forced to stay the same size, there may be some overlap between the FlowContainer's children, but should no longer crash.
@aaronp64 aaronp64 force-pushed the flowcontainer_resort_crash branch from 7425f49 to 5682cc7 Compare July 21, 2024 17:10
@akien-mga akien-mga merged commit 3018178 into godotengine:master Jul 22, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga changed the title Avoid FlowContainer crash with TextureRect using EXPAND_FIT_* expand modes Avoid FlowContainer crash with TextureRect using EXPAND_FIT_* expand modes Jul 25, 2024
@aaronp64 aaronp64 deleted the flowcontainer_resort_crash branch August 22, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changing Label in FlowContainer with TextureRect will cause crash
3 participants