From 1e019b1c1e9b4245372e4586604f6ed015216773 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Tue, 4 May 2021 09:18:21 +0200 Subject: [PATCH] TextEditor: Fix compile with Qt6 toStdList() has been removed in Qt6. Amends a2dadb3d0bf4f8850cc0da. Change-Id: Id2032d7e0a0c3345614bc56d98152c41f199af07 Reviewed-by: Eike Ziller --- .../texteditor/snippets/snippetoverlay.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/plugins/texteditor/snippets/snippetoverlay.cpp b/src/plugins/texteditor/snippets/snippetoverlay.cpp index f35c8b6aa91..2788ccf50a7 100644 --- a/src/plugins/texteditor/snippets/snippetoverlay.cpp +++ b/src/plugins/texteditor/snippets/snippetoverlay.cpp @@ -128,20 +128,17 @@ QTextCursor SnippetOverlay::previousSelectionCursor(const QTextCursor &cursor) c if (previousVariableIndex < 0) previousVariableIndex = m_variables.size(); - auto equivalents = m_variables[previousVariableIndex].toStdList(); - equivalents.reverse(); - for (int selectionIndex : equivalents) { - if (selections[selectionIndex].m_cursor_end.position() < cursor.position()) - return cursorForIndex(selectionIndex); + const QList &equivalents = m_variables[previousVariableIndex]; + for (int i = equivalents.size() - 1; i >= 0; --i) { + if (selections.at(equivalents.at(i)).m_cursor_end.position() < cursor.position()) + return cursorForIndex(equivalents.at(i)); } return cursorForIndex(m_variables[previousVariableIndex].last()); } // currently not over a variable simply select the previous available one - auto reverse = selections.toStdList(); - reverse.reverse(); - for (const OverlaySelection &candidate : reverse) { - if (candidate.m_cursor_end.position() < cursor.position()) - return cursorForSelection(candidate); + for (int i = selections.size() - 1; i >= 0; --i) { + if (selections.at(i).m_cursor_end.position() < cursor.position()) + return cursorForIndex(i); } return cursorForSelection(selections.last()); }