Fixed an issue where ScrollableContainer could round its size to zero.

Also added a sizing check to prevent application hangs on zero-sized containers.
This commit is contained in:
Leon Styhre 2022-01-29 11:06:58 +01:00
parent 24f65a2560
commit 4b1138ebc7

View file

@ -71,12 +71,17 @@ void ScrollableContainer::reset()
if (mChildren.front()->getSize().y > mSize.y) { if (mChildren.front()->getSize().y > mSize.y) {
float numLines {mSize.y / combinedHeight}; float numLines {mSize.y / combinedHeight};
mSize.y = floorf(numLines) * combinedHeight; mSize.y = floorf(numLines) * combinedHeight;
if (mSize.y == 0.0f)
mSize.y = combinedHeight;
} }
} }
} }
void ScrollableContainer::update(int deltaTime) void ScrollableContainer::update(int deltaTime)
{ {
if (mSize == glm::vec2 {0.0f, 0.0f})
return;
// Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled; // Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled;
if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() || if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() ||
!mWindow->getAllowTextScrolling()) { !mWindow->getAllowTextScrolling()) {