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:
parent
d59230aecc
commit
6bc51f97e4
1 changed files with 10 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue