Browse Source

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

v6.1.6
reuk 4 years ago
parent
commit
6bc51f97e4
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      modules/juce_gui_basics/layout/juce_Grid.cpp

+ 10
- 0
modules/juce_gui_basics/layout/juce_Grid.cpp 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;


Loading…
Cancel
Save