Skip to content

Fix Control minimum size check too aggressive#116343

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
kitbdev:fix-control-error-freeze
Feb 16, 2026
Merged

Fix Control minimum size check too aggressive#116343
Repiteo merged 1 commit into
godotengine:masterfrom
kitbdev:fix-control-error-freeze

Conversation

@kitbdev

@kitbdev kitbdev commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

CodeTextEditor changes the RichTextLabel's minimum size based on its content height when it resizes. This causes it to resize again with a different content height and it continues going back and forth between 2 values.
RichTextLabel can have a different content height even if only the minimum size height changes, because the scrollbar may show or not depending on if it fits. There is also no reserve scrollbar mode like ScrollContainer has.

The error RichTextLabel changes size and causes its minimum height to be set which calls Control::update_minimum_size() then Control::_update_minimum_size(), which causes the size to change again. But this time the HBoxContainer it is in gets resorted before Control::_update_minimum_size() is called since it is deferred. The HBoxContainer resort updates the size which sets the minimum height again back to the original value. Previously (before #115596) it would then just be ignored since it has the same value as before, even though it changed and its effects got overridden. So in some ways it would be correct to update the size again in this case, but it also allows infinite loops to happen.

In the future, RichTextLabel should probably be able to reserve the scrollbar space or do something for when it is at minimum size, since it isn't great at either of the values it is trying to use.
At the lower height (26) without a scrollbar, you can see the E r r text go outside of its rect (4.6, this PR):
image

And at the higher height (62) with a scrollbar, the scrollbar cannot move and the text is on one line (master, increasing size causes the freeze):
image

It looks like there are also cases where the change in #115596 updates the size where it isn't necessary, its too aggressive in updating sizes. So I am reverting that change and implementing a different fix for #109497 that only affects Controls that are made invisible but also doesn't resize them when invisible.

@kitbdev kitbdev added this to the 4.7 milestone Feb 16, 2026
@kitbdev kitbdev requested a review from a team as a code owner February 16, 2026 03:48
@kitbdev kitbdev changed the title Fix Control minimum size check too agressive Feb 16, 2026
@Repiteo Repiteo merged commit 3110686 into godotengine:master Feb 16, 2026
20 checks passed
@Repiteo

Repiteo commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Thanks!

@kitbdev kitbdev deleted the fix-control-error-freeze branch February 16, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment