Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75863

QTextDocumentLayoutPrivate::layoutFlow() accesses layout->lineAt(0), index out of range

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.9.6
    • Widgets: Layout
    • None
    • Windows

    Description

      There sometimes is a crash in (index 0 out of range)

      qtextdocumentlayout.cpp::2497
      QFixed height = QFixed::fromReal(layout->lineAt(0).height());

      void QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::Iterator it, QTextLayoutStruct *layoutStruct, int layoutFrom, int layoutTo, QFixed width)

      My code calls mergeCharFormat(), this is the call stack

      QTextLine::height() Line 1497 C++
      > QTextDocumentLayoutPrivate::layoutFlow(QTextFrame::iterator it, QTextLayoutStruct * layoutStruct, int layoutFrom, int layoutTo, QFixed width) Line 2497 C++
      QTextDocumentLayoutPrivate::layoutFrame(QTextFrame * f, int layoutFrom, int layoutTo, QFixed frameWidth, QFixed frameHeight, QFixed parentY) Line 2207 C++
      QTextDocumentLayoutPrivate::layoutFrame(QTextFrame * f, int layoutFrom, int layoutTo, QFixed parentY) Line 2094 C++
      QTextDocumentLayout::doLayout(int from, int oldLength, int length) Line 3001 C++
      QTextDocumentLayout::documentChanged(int from, int oldLength, int length) Line 2964 C++
      QTextDocumentPrivate::finishEdit() Line 1223 C++
      QTextDocumentPrivate::endEditBlock() Line 1202 C++
      QTextDocumentPrivate::setCharFormat(int pos, int length, const QTextCharFormat & newFormat, QTextDocumentPrivate::FormatChangeMode mode) Line 775 C++
      QTextCursorPrivate::setCharFormat(const QTextCharFormat & _format, QTextDocumentPrivate::FormatChangeMode changeMode) Line 867 C++
      QTextCursor::mergeCharFormat(const QTextCharFormat & modifier) Line 1943 C++
      SMUHelpBrowser::emphasizeWordsInFindMode() Line 800 C++

       

      This is the user code

      void SMUHelpBrowser::emphasizeWordsInFindMode()
      {
      bool wholeWords{};
      const QStringList words(m_Dialog->getWordsToFind(wholeWords));
      QTextDocument* doc{document()};
      if (words.isEmpty())

      { doc->undo(); return; }

      for (const auto word : words)
      {
      int numFound{};
      for (QTextCursor csr(doc->begin()); !csr.isNull() && !csr.atEnd() && numFound < 15
      {
      QTextCharFormat format(csr.charFormat());
      format.setForeground(Qt::red);
      csr = doc->find(word, csr, wholeWords ? QTextDocument::FindWholeWords : QTextDocument::FindFlag(0));
      if (!csr.isNull() && !csr.atEnd())
      {
      csr.movePosition(QTextCursor::WordRight, QTextCursor::KeepAnchor);
      if (!csr.isNull() && !csr.atEnd() && csr.hasSelection())

      { csr.mergeCharFormat(format); }

      numFound++;
      }
      }
      }
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            bgtrackqtunameegon richard dengler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes