qt6-bb10/src/widgets
Eskil Abrahamsen Blomfeldt 27bc4c4ce5 QPlainTextEdit: Fix crash on complex undo w/full width selection
Say you have a document of two blocks of text.

When you select a block of text in the document and then replace this
with a new empty block (by pressing enter) and then subsequently
undo this action, the following three steps are performed as a
chain of undo commands:

1. Remove the empty block at the beginning of the document
2. Insert a new empty block at the beginning of the document
3. Insert the text back into the first block

Since a block is removed and inserted in the same go, both blocks
require a relayout, since the accumulated change spans both blocks.
However, in QPlainTextDocumentLayout we would only look at the max
of either removed chars or added chars. This would match the text
length of the first block at this point, so we would only relayout
that block. However, since we are also removing characters, the
actual accumulated change to the document is larger. We should
relayout any block touched by the sum of the added and removed
character counts.

Missing this, the paint event would later query
block.layout()->lineForTextPosition(0) which would give an invalid
line despite the fact that the block.length() > 0. This caused
a crash in the paint event when the full width selection was
turned on.

Note that the logic here was only recently updated to include the
removed characters at all in the logic, by the SHA1:
2983cb9531.

[ChangeLog][QPlainTextEdit] Fixed a crash when using full width
selections and issuing a complex undo command chain which removes
and inserts an empty block in one go.

Task-number: QTBUG-36415
Change-Id: Iafe8a69e455e0c713a48714f10f0cace69c84f51
Reviewed-by: Axel Rasmussen <axel.rasmussen1@gmail.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
2014-09-30 10:21:39 +02:00
..
accessible Remove useless if 2014-02-10 11:19:21 +01:00
dialogs QFileDialog: save and restore all settings even if widgets not used 2014-09-01 12:54:48 +02:00
doc Fix typo in QGraphicsView documentation. 2014-07-07 11:44:16 +02:00
effects Doc: Adding mark-up to boolean default values. 2013-10-08 00:46:27 +02:00
graphicsview Add missing private headers warning 2014-09-04 22:58:57 +02:00
itemviews Document non-intuitive behavior of QTreeWidgetItem::setHidden(). 2014-09-22 12:38:17 +02:00
kernel OS X: Fix menu item shortcuts without modifiers 2014-09-22 14:32:28 +02:00
statemachine
styles QMacStyle: Generalize Cocoa control rendering 2014-09-29 13:39:06 +02:00
util Fix pixel noise in X11 systray icons that are not 22x22 2014-06-30 15:19:24 +02:00
widgets QPlainTextEdit: Fix crash on complex undo w/full width selection 2014-09-30 10:21:39 +02:00
Qt5WidgetsConfigExtras.cmake.in CMake: Include the definition of the Qt5::AccessibleFactory target. 2014-04-16 15:21:50 +02:00
Qt5WidgetsMacros.cmake
QtWidgets.dynlist
widgets.pro make QtWidgets claim style plugins 2014-07-16 13:13:29 +02:00