From 8fbedf2196a292fe2affcf83ddc846b9c852772a Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 21 Apr 2020 09:55:05 +0200 Subject: QTextDocument: fix an off-by-one in the changed signal for lists When blocks are added or removed in block groups, i.e. items added or removed from text lists, the whole group is marked as changed, but the calculation of the before/after group length would be one off. That was reflected in the contentsChange signal. Add unit test. Since the whole group changes when list items are added, text is removed and the change-begin is not where the cursor was when the change was made. Fixes: QTBUG-82455 Pick-to: 6.2 5.15 Change-Id: I99ee2cfef4944fcac8aca492741fd0f3b0de4920 Reviewed-by: Volker Hilsheimer Reviewed-by: Eirik Aavitsland --- src/gui/text/qtextdocument_p.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qtextdocument_p.cpp') diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 69730256cb..f73475226f 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -382,8 +382,11 @@ int QTextDocumentPrivate::insert_block(int pos, uint strPos, int format, int blo Q_ASSERT(blocks.length() == fragments.length()); QTextBlockGroup *group = qobject_cast(objectForFormat(blockFormat)); - if (group) + if (group) { group->blockInserted(QTextBlock(this, b)); + docChangeOldLength--; + docChangeLength--; + } QTextFrame *frame = qobject_cast(objectForFormat(formats.format(format))); if (frame) { -- cgit v1.2.3