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

QAbstractTextDocumentLayout::documentChanged receives wrong count of added chars in some situations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.2
    • GUI: Text handling
    • None
    • Windows

    Description

      The documentation says that the 3rd parameter of QAbstractTextDocumentLayout::documentChanged should receive the number of characters added to the document.

      However, dozens of functions in QTextDocument call this method to invalidate the layout, passing as the 3rd parameter the total number of characters in the document, even though no change to the number of characters were made. For example, QTextDocument::setDefaultFont (and other setters):

      void QTextDocument::setDefaultFont(const QFont &font)
      {
          Q_D(QTextDocument);
          d->setDefaultFont(font);
          if (d->lout)
              d->lout->documentChanged(0, 0, d->length());
      }
      
      [...]
      
      void QTextDocument::setDefaultTextOption(const QTextOption &option)
      {
          Q_D(QTextDocument);
          d->defaultTextOption = option;
          if (d->lout)
              d->lout->documentChanged(0, 0, d->length());
      }

      This makes this function unsuited for position tracking in the layout. Besides, it disagrees with what documentation says.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            felipef Felipe Goron Farinon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes