fixed crash when all windows were hidden

This commit is contained in:
Christian Burger 2022-05-06 22:15:34 +02:00
parent 320f5ba63a
commit b723aa5f33

View file

@ -66,10 +66,16 @@ namespace krikkel::NCurses
void VerticalTilingWindowManager::updateLayout() void VerticalTilingWindowManager::updateLayout()
{ {
size_t stackSize = visibleStack.size();
if(stackSize == 0)
{
rootWindow->clear();
return;
}
scoped_lock lock(*ncursesMutex); scoped_lock lock(*ncursesMutex);
int availableWidth = rootWindow->width(); int availableWidth = rootWindow->width();
int availableHeight = rootWindow->height(); int availableHeight = rootWindow->height();
size_t stackSize = visibleStack.size();
int windowHeight = availableHeight / stackSize - 1; int windowHeight = availableHeight / stackSize - 1;
if((windowHeight + 1) * stackSize < availableHeight) if((windowHeight + 1) * stackSize < availableHeight)