Merge pull request #114541 from kitbdev/fix-sc-inf-loop
Fix SplitContainer set desired size infinite loop
This commit is contained in:
commit
b8e4523224
2 changed files with 9 additions and 3 deletions
|
|
@ -290,14 +290,14 @@ void TileMapLayerEditorTilesPlugin::_update_source_display() {
|
|||
TileSetScenesCollectionSource *scenes_collection_source = Object::cast_to<TileSetScenesCollectionSource>(source);
|
||||
|
||||
if (atlas_source) {
|
||||
tile_atlas_view->show();
|
||||
scene_tiles_list->hide();
|
||||
invalid_source_label->hide();
|
||||
tile_atlas_view->show();
|
||||
_update_atlas_view();
|
||||
} else if (scenes_collection_source) {
|
||||
tile_atlas_view->hide();
|
||||
scene_tiles_list->show();
|
||||
invalid_source_label->hide();
|
||||
scene_tiles_list->show();
|
||||
_update_scenes_collection_view();
|
||||
} else {
|
||||
tile_atlas_view->hide();
|
||||
|
|
|
|||
|
|
@ -410,6 +410,7 @@ void SplitContainer::_set_desired_sizes(const PackedInt32Array &p_desired_sizes,
|
|||
if (Math::is_zero_approx(shrink_amount)) {
|
||||
break;
|
||||
}
|
||||
const real_t prev_available_space = available_space;
|
||||
for (StretchData &sdata : stretch_data) {
|
||||
if (sdata.stretch_ratio <= 0 || sdata.final_size <= sdata.min_size) {
|
||||
continue;
|
||||
|
|
@ -419,6 +420,10 @@ void SplitContainer::_set_desired_sizes(const PackedInt32Array &p_desired_sizes,
|
|||
const real_t size_diff = prev_size - sdata.final_size;
|
||||
available_space += size_diff;
|
||||
}
|
||||
if (Math::is_equal_approx(available_space, prev_available_space)) {
|
||||
// Shrinking can fail due to values being too small to have an effect but too large for `is_zero_approx`.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Shrink non-expanding children.
|
||||
|
|
@ -454,6 +459,7 @@ void SplitContainer::_set_desired_sizes(const PackedInt32Array &p_desired_sizes,
|
|||
}
|
||||
// Don't shrink smaller than needed.
|
||||
target_size = MAX(target_size, largest_size + available_space / largest_count);
|
||||
const real_t prev_available_space = available_space;
|
||||
for (StretchData &sdata : stretch_data) {
|
||||
if (sdata.final_size <= sdata.min_size || (skip_priority_child && sdata.priority)) {
|
||||
continue;
|
||||
|
|
@ -465,7 +471,7 @@ void SplitContainer::_set_desired_sizes(const PackedInt32Array &p_desired_sizes,
|
|||
available_space += size_diff;
|
||||
}
|
||||
}
|
||||
if (Math::is_zero_approx(available_space)) {
|
||||
if (Math::is_zero_approx(available_space) || Math::is_equal_approx(available_space, prev_available_space)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue