forked from qt-creator/qt-creator
Editor: fix crashing on updating snippet selections
The final selection is not tracked in m_selections and needs to be handled explicitly. Also add an assert preventing unconditionally accessing an out of bounds element of m_selections. Fixes: QTCREATORBUG-28631 Change-Id: I1898418b1126bdaffccbdf0e483e2c659d191917 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -38,8 +38,13 @@ void SnippetOverlay::setFinalSelection(const QTextCursor &cursor, const QColor &
|
|||||||
void SnippetOverlay::updateEquivalentSelections(const QTextCursor &cursor)
|
void SnippetOverlay::updateEquivalentSelections(const QTextCursor &cursor)
|
||||||
{
|
{
|
||||||
const int ¤tIndex = indexForCursor(cursor);
|
const int ¤tIndex = indexForCursor(cursor);
|
||||||
|
if (currentIndex == m_finalSelectionIndex) {
|
||||||
|
accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (currentIndex < 0)
|
if (currentIndex < 0)
|
||||||
return;
|
return;
|
||||||
|
QTC_ASSERT(currentIndex < m_selections.size(), return);
|
||||||
const QString ¤tText = cursorForIndex(currentIndex).selectedText();
|
const QString ¤tText = cursorForIndex(currentIndex).selectedText();
|
||||||
const QList<int> &equivalents = m_variables.value(m_selections[currentIndex].variableIndex);
|
const QList<int> &equivalents = m_variables.value(m_selections[currentIndex].variableIndex);
|
||||||
for (int i : equivalents) {
|
for (int i : equivalents) {
|
||||||
|
Reference in New Issue
Block a user