Fixed an issue where single-line scrollable containers could make the application hang.

This commit is contained in:
Leon Styhre 2023-01-16 17:20:54 +01:00
parent 5d5eaf2de2
commit e096aef4e4

View file

@ -78,6 +78,8 @@ void ScrollableContainer::reset()
if (mChildren.front()->getSize().y > mSize.y) { if (mChildren.front()->getSize().y > mSize.y) {
if (mVerticalSnap) { if (mVerticalSnap) {
float numLines {std::floor(mSize.y / combinedHeight)}; float numLines {std::floor(mSize.y / combinedHeight)};
if (numLines == 0)
numLines = 1;
mAdjustedHeight = std::round(numLines * combinedHeight); mAdjustedHeight = std::round(numLines * combinedHeight);
} }
else { else {
@ -145,6 +147,8 @@ void ScrollableContainer::update(int deltaTime)
if (!mUpdatedSize) { if (!mUpdatedSize) {
if (mVerticalSnap) { if (mVerticalSnap) {
float numLines {std::floor(mSize.y / combinedHeight)}; float numLines {std::floor(mSize.y / combinedHeight)};
if (numLines == 0)
numLines = 1;
mAdjustedHeight = std::round(numLines * combinedHeight); mAdjustedHeight = std::round(numLines * combinedHeight);
} }
else { else {