Fix crash when removing built-in snippets

Snippets collection managed the snippets with persistent iterators to
the "end" of the active snippets. Qt 5's QList was nicely updating
iterators even on non-const operations, but that has changed in Qt 6.

Don't use iterators, simply work with the count of active items.

Fixes: QTCREATORBUG-26648
Task-number: QTCREATORBUG-24098
Change-Id: Icc13274daf0e87d0562d80d7bc763c863d5da075
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2021-12-03 12:22:16 +01:00
parent 4a37833803
commit 8d08196a21
2 changed files with 27 additions and 21 deletions

View File

@@ -121,7 +121,7 @@ private:
// active. Specifically, removed built-in snippets are kept as the last ones (for each
// group there is a iterator that marks the logical end).
QVector<QList<Snippet> > m_snippets;
QVector<QList<Snippet>::iterator> m_activeSnippetsEnd;
QVector<int> m_activeSnippetsCount;
QHash<QString, int> m_groupIndexById;
};