diff --git a/scene/gui/flow_container.cpp b/scene/gui/flow_container.cpp index eedcd473fbe..d32c75fbcdc 100644 --- a/scene/gui/flow_container.cpp +++ b/scene/gui/flow_container.cpp @@ -30,6 +30,7 @@ #include "flow_container.h" +#include "scene/gui/texture_rect.h" #include "scene/theme/theme_db.h" 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(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)) { child_size.width = line_data.min_line_height; }