Merge pull request #94286 from aaronp64/flowcontainer_resort_crash
Avoid `FlowContainer` crash with `TextureRect` using EXPAND_FIT_* expand modes
This commit is contained in:
commit
3018178d3f
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "flow_container.h"
|
#include "flow_container.h"
|
||||||
|
|
||||||
|
#include "scene/gui/texture_rect.h"
|
||||||
#include "scene/theme/theme_db.h"
|
#include "scene/theme/theme_db.h"
|
||||||
|
|
||||||
struct _LineData {
|
struct _LineData {
|
||||||
@ -203,7 +204,23 @@ void FlowContainer::_resort() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vertical) { /* VERTICAL */
|
bool is_unsupported_texture_rect = false;
|
||||||
|
if (lines_data.size() > 1) {
|
||||||
|
TextureRect *trect = Object::cast_to<TextureRect>(child);
|
||||||
|
if (trect) {
|
||||||
|
TextureRect::ExpandMode mode = trect->get_expand_mode();
|
||||||
|
if (mode == TextureRect::EXPAND_FIT_WIDTH || mode == TextureRect::EXPAND_FIT_WIDTH_PROPORTIONAL ||
|
||||||
|
mode == TextureRect::EXPAND_FIT_HEIGHT || mode == TextureRect::EXPAND_FIT_HEIGHT_PROPORTIONAL) {
|
||||||
|
is_unsupported_texture_rect = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_unsupported_texture_rect) {
|
||||||
|
// Temporary fix for editor crash. Changing size of TextureRect with EXPAND_FIT_* ExpandModes can lead to infinite loop if child items are moved between lines.
|
||||||
|
WARN_PRINT_ONCE("TextureRects with Fit Expand Modes are currently not supported inside FlowContainers with multiple lines");
|
||||||
|
child_size = child->get_size();
|
||||||
|
} else if (vertical) { /* VERTICAL */
|
||||||
if (child->get_h_size_flags().has_flag(SIZE_FILL) || child->get_h_size_flags().has_flag(SIZE_SHRINK_CENTER) || child->get_h_size_flags().has_flag(SIZE_SHRINK_END)) {
|
if (child->get_h_size_flags().has_flag(SIZE_FILL) || child->get_h_size_flags().has_flag(SIZE_SHRINK_CENTER) || child->get_h_size_flags().has_flag(SIZE_SHRINK_END)) {
|
||||||
child_size.width = line_data.min_line_height;
|
child_size.width = line_data.min_line_height;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user