-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
Qt Creator 18.0.0
-
None
-
-
dcefb77e0 (master)
Under specific cases while typing a closing ) overtop of an existing paren, qt creator will crash.
Debugging shows that the crash is because the parameter is empty.
autocompleter.cpp line 162
QString AutoCompleter::autoComplete(QTextCursor &cursor, const QString &textToInsert, bool skipChars) const { const bool checkBlockEnd = m_allowSkippingOfBlockEnd; m_allowSkippingOfBlockEnd = false; // consume blockEnd. QString autoText = replaceSelection(cursor, textToInsert); if (!autoText.isEmpty()) return autoText; QTextDocument *doc = cursor.document(); const QChar lookAhead = doc->characterAt(cursor.selectionEnd()); if (m_overwriteClosingChars && (textToInsert == lookAhead)) skipChars = true; int skippedChars = 0; if (isQuote(textToInsert) && m_autoInsertQuotes && contextAllowsAutoQuotes(cursor, textToInsert)) { autoText = insertMatchingQuote(cursor, textToInsert, lookAhead, skipChars, &skippedChars); } else if (m_autoInsertBrackets && contextAllowsAutoBrackets(cursor, textToInsert)) { if (fixesBracketsError(textToInsert, cursor)) <------ crash here return QString();
autocompleter line 71
static bool fixesBracketsError(const QString &textToInsert, const QTextCursor &cursor) { const QChar character = textToInsert.at(0); <-- crash here
The empty string happens in the following situation:
If added a simple check to the beggining of both functions and see no ill effect and the crash no longer reproduces.
if(textToInsert.isEmpty()) return false;
For Gerrit Dashboard: QTCREATORBUG-33235 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
663630,2 | Editor: fix crash after jumping over auto completed text | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |