Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.14.1
-
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
Issue Links
- duplicates
-
QTBUG-49062 Wrong values appear in QTextDocument::contentsChange() signal
- Closed
- resulted in
-
QTBUG-113865 [Text Editor]Using undo function causes the app to crash
- Closed