From 7b5e4b6944a85966a9db3f5eac7dba4695024b00 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 16 Mar 2020 10:07:20 +0100 Subject: Don't call QSet::erase() on an end iterator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hash.erase(hash.constFind()) is bound to crash if the hash doesn't contain the item we're looking for. Change-Id: Icbefca87b0258970373ec55d5dc113e6ab39c5f0 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/itemmodels/qabstractitemmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp') diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index addeeafd45..41bdaa2ac5 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -951,7 +951,9 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent, for (QVector::const_iterator it = persistent_invalidated.constBegin(); it != persistent_invalidated.constEnd(); ++it) { QPersistentModelIndexData *data = *it; - persistent.indexes.erase(persistent.indexes.constFind(data->index)); + auto index = persistent.indexes.constFind(data->index); + if (index != persistent.indexes.constEnd()) + persistent.indexes.erase(index); data->index = QModelIndex(); } } -- cgit v1.2.3