iconGrid/iconGridLayout: Make sure to always update best size

When selecting the best icon size for the available area, we
iterate from the biggest icon size to the smallest one, and
stop when finding a size that fits the available area.

However, the 'bestSize' variable is only updated when the
available area is positive. This is problematic in super bad
cases like when none of the icon sizes actually fit the availabe
area, which was hit with a previous iteration of this branch.

Make sure to update the best size while iterating, so that the
smallest size is selected even in such bad cases.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1510>
This commit is contained in:
Georges Basile Stavracas Neto 2020-11-30 22:14:17 -03:00 committed by Marge Bot
parent 34e38a835c
commit 4863c498b2

View File

@ -429,10 +429,10 @@ var IconGridLayout = GObject.registerClass({
this._pageHeight - usedHeight - rowSpacingPerPage -
this._pagePadding.top - this._pagePadding.bottom;
if (emptyHSpace >= 0 && emptyVSpace > 0) {
bestSize = size;
bestSize = size;
if (emptyHSpace >= 0 && emptyVSpace > 0)
break;
}
}
return bestSize;