Skip to content

Commit

Permalink
Don't try to insert items out of bounds
Browse files Browse the repository at this point in the history
The q_items list is only used to hold a full list of all items in the
layout. They are kept in order for a linear layout, so that users see
them in the right order, but there's no real guarantee for that anyway
if combined with spacers and other non-items.

Continue to try keeping the order, but ensure indices that are out of
bounds are treated as appends to the list.

Change-Id: I22721c1fa8b329c5d16ad00c5cb780e099693cda
Reviewed-by: Simon Hausmann <[email protected]>
  • Loading branch information
laknoll committed Oct 30, 2019
1 parent cd04181 commit bc4e7ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/util/qgridlayoutengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index)
{
maybeExpandGrid(item->lastRow(), item->lastColumn());

if (index == -1)
if (index < 0 || index >= q_items.size())
q_items.append(item);
else
q_items.insert(index, item);
Expand Down

0 comments on commit bc4e7ae

Please sign in to comment.