diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-26 10:25:41 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-26 10:25:41 +0100 |
commit | bfd5e098794ecb1f563b53e29f6981fda86381e9 (patch) | |
tree | a0477e9629974b108f3a663f00e526c81ad6e4a7 /scene/gui/item_list.cpp | |
parent | 55f86e9b7b25e44e5fe7acd9e55d1e26c5a67e95 (diff) |
Range: Fix cases where max was set to or below min value
It will now raise an error whenever this happens so that we can fix
these situations. `max == min` is not allowed as it could lead to
divisions by zero in ratios, and `max < min` doesn't make much sense.
Fixes #33907.
Diffstat (limited to 'scene/gui/item_list.cpp')
-rw-r--r-- | scene/gui/item_list.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 1406586361..3884622942 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -969,16 +969,16 @@ void ItemList::_notification(int p_what) { } if (all_fit) { - float page = size.height - bg->get_minimum_size().height; + float page = MAX(0, size.height - bg->get_minimum_size().height); float max = MAX(page, ofs.y + max_h); if (auto_height) auto_height_value = ofs.y + max_h + bg->get_minimum_size().height; - scroll_bar->set_max(max); - scroll_bar->set_page(page); if (max <= page) { scroll_bar->set_value(0); scroll_bar->hide(); } else { + scroll_bar->set_max(max); + scroll_bar->set_page(page); scroll_bar->show(); if (do_autoscroll_to_bottom) |