Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-33235

Qt Creator crash on autocomplete

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • Qt Creator 18.0.0
    • Qt Creator 18.0.0
    • Editors
    • None
    • Linux/X11
    • 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

            davschul David Schulz
            daniel.trevitz@belden.com Daniel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes