From bc4e7aecc0db534ad4e52691f70c98f5ad643230 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 30 Oct 2019 11:42:58 +0100 Subject: Don't try to insert items out of bounds 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 --- src/gui/util/qgridlayoutengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp index 33adac40b2..bff5b4ddde 100644 --- a/src/gui/util/qgridlayoutengine.cpp +++ b/src/gui/util/qgridlayoutengine.cpp @@ -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); -- cgit v1.2.3