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

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

    XMLWordPrintable

Details

    • 8fbedf2196a292fe2affcf83ddc846b9c852772a (qt/qtbase/dev) 2d51988904d9b117fe0fb0b9fd2ac666a61cd973 (qt/qtbase/6.2) ea59faf5a5 (qt/tqtc-qtbase/5.15-opensource)

    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. qtbug82455.zip
          2 kB
        2. mainwindow.h
          2 kB

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews