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 crash with AspectRatioContainer and TextureRect #73396

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Feb 15, 2023

Fixes crash part of #73071

This is a temporary solution, and the only case that crashes the editor. Proportional TextureRect does not make sense with AspectRatioContainer anyway, because both functionalities solve the same problem.

@YuriSizov
Copy link
Contributor

@akien-mga suggests we go with this hack to address the immediate reported issue, but add an experimental flag to the expand mode property, so people know we are going to change it (and I assume we're on the same page about changing it now).

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 16, 2023

I think it would be great if the intended solution was implemented soon, even if it's not going to be merged until later.

add an experimental flag to the expand mode property

How to make property experimental? AFAIK this only applies to whole classes.

@YuriSizov
Copy link
Contributor

I guess we can mark the class and add a note in the class' description.

I think it would be great if the intended solution was implemented soon, even if it's not going to be merged until later.

Well, we do have an eager contributor to work on it 🙃

@akien-mga
Copy link
Member

How to make property experimental? AFAIK this only applies to whole classes.

#64982 actually implemented support for marking any element as experimental, so it works for <member> too.

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 16, 2023

But I don't see any property hint or usage to mark it. I guess it just wasn't added yet 🤔
EDIT: Ah yes, a change in object.h. See you in two weeks.

@akien-mga
Copy link
Member

akien-mga commented Feb 16, 2023

There's no property hint for any of these, you have to add it manually in the XML. is_experimental="true"

diff --git a/doc/classes/TextureRect.xml b/doc/classes/TextureRect.xml
index 460ffbbb80..1bebf65261 100644
--- a/doc/classes/TextureRect.xml
+++ b/doc/classes/TextureRect.xml
@@ -10,7 +10,7 @@
 		<link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/676</link>
 	</tutorials>
 	<members>
-		<member name="expand_mode" type="int" setter="set_expand_mode" getter="get_expand_mode" enum="TextureRect.ExpandMode" default="0">
+		<member name="expand_mode" type="int" setter="set_expand_mode" getter="get_expand_mode" enum="TextureRect.ExpandMode" is_experimental="true" default="0">
 			Defines how minimum size is determined based on the texture's size. See [enum ExpandMode] for options.
 		</member>
 		<member name="flip_h" type="bool" setter="set_flip_h" getter="is_flipped_h" default="false">

Not sure what's the canonical place for it in the sequence of arguments, you'll have to test and see what doctool does with it.

I wouldn't bother adding anything to object.h now for this, this would be 4.1 material.

@KoBeWi KoBeWi requested a review from a team as a code owner February 16, 2023 13:35
@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 16, 2023

Adding usage flag in object.h and making it work is a matter of few lines, but right now the functionality only exists inside documentation. It doesn't have neat inspector warnings like in the proposal, so there is no point in doing anything more than modifying XML for now .-.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@akien-mga akien-mga merged commit 25da47e into godotengine:master Feb 16, 2023
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the sorry branch February 16, 2023 17:38
aaronp64 added a commit to aaronp64/godot that referenced this pull request Jul 21, 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.
Akeal pushed a commit to Akeal/godot that referenced this pull request Jul 24, 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.
Luis-Wong pushed a commit to Luis-Wong/godot that referenced this pull request Jul 26, 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.
RadiantUwU pushed a commit to RadiantUwU/godot that referenced this pull request Jul 27, 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.
2nafish117 pushed a commit to 2nafish117/godot that referenced this pull request Aug 5, 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.
chryan pushed a commit to chryan/godot that referenced this pull request Aug 6, 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.
maidopi-usagi pushed a commit to maidopi-usagi/godot that referenced this pull request Sep 11, 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.
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.

3 participants