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

QTextDocument::contentsChange(int,int,int) values are incompatible with QTextCursor

    XMLWordPrintable

    Details

    • Commits:
      8fbedf2196a292fe2affcf83ddc846b9c852772a (qt/qtbase/dev) 2d51988904d9b117fe0fb0b9fd2ac666a61cd973 (qt/qtbase/6.2)

      Description

      QTextDocument internally makes use of hidden or non visual characters (e.g. QTBUG-80662 - ) but the API's for accessing a modifying a QTextDocument (so either the limited API of QTextDocument itself or QTextCursor) do not consistently reflect the data that is exposed.

      QTextDocument::contentsChange(int position,int removed,int added) includes character counts which take into account at least some of the hidden characters used internally, e.g. ones used to mark lists. QTextCursor does not take these extra characters into account and so it is possible for contentsChange to emit values which according to QTextCursor cannot exist (see attached example).

      A simpler example of this is as reported in QTBUG-80662 - where QTextCursor and QTextDocument report different document lengths (QTextCursor does not include the extra hidden character).

      Because the numbers do not line up, it is not possible to accurately detect and act upon small localized changes to the document. This makes things like shadow documents (helpful for collaborative text document merges for example) or simple synchronization of multiple QTextDocument instances (to workaround QQuickTextEdit limitations for example) is not possible without wiping and recreating the whole document on each change.

       

        Attachments

        1. mainwindow.h
          2 kB
        2. qtbug82455.zip
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            vgt Eirik Aavitsland
            Reporter:
            aelm Andrew Forrest
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews