1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Grid: Avoid crashing in performLayout when the grid contains no items

This commit is contained in:
reuk 2021-10-13 13:10:11 +01:00
parent d59230aecc
commit 6bc51f97e4
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -833,6 +833,9 @@ struct Grid::AutoPlacement
template <typename Accessor>
static PlacementHelpers::LineRange findFullLineRange (const ItemPlacementArray& items, Accessor&& accessor)
{
if (items.isEmpty())
return { 1, 1 };
const auto combine = [&accessor] (const auto& acc, const auto& item)
{
const auto newRange = accessor (item);
@ -1052,6 +1055,13 @@ struct GridTests : public UnitTest
using Tr = Grid::TrackInfo;
using Rect = Rectangle<float>;
beginTest ("Layout calculation of an empty grid is a no-op");
{
const Rectangle<int> bounds { 100, 200 };
Grid grid;
grid.performLayout (bounds);
}
{
Grid grid;