qt6-bb10/tests/auto/widgets/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
..
qabstractbutton expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
qabstractscrollarea
qabstractslider Respect scrollbar position setting on Mac 2014-03-20 19:01:53 +01:00
qabstractspinbox
qbuttongroup
qcalendarwidget expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
qcheckbox
qcombobox Use QModelIndex to get the data from underlying model 2014-06-19 17:23:30 +02:00
qcommandlinkbutton
qdatetimeedit
qdial
qdialogbuttonbox
qdockwidget QNX: Fix QDockWidget autotest 2014-04-14 20:03:30 +02:00
qdoublespinbox BlackBerry: Fix QDoubleSpinBox autotests 2014-04-14 20:03:30 +02:00
qfocusframe
qfontcombobox
qgroupbox
qkeysequenceedit QKeySequenceEdit: simplify clear() 2013-11-14 18:59:54 +01:00
qlabel expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
qlcdnumber
qlineedit Show the correct cursor for QLineEdit's side buttons. 2014-08-12 14:56:23 +02:00
qmainwindow Replace hard-coded qWait() by QTRY_COMPARE/VERIFY in widget tests. 2014-05-26 15:06:12 +02:00
qmdiarea Merge remote-tracking branch 'origin/release' into stable 2014-05-01 13:08:42 +02:00
qmdisubwindow QNX: Fix QMdiWindow autotests 2014-06-25 14:43:13 +02:00
qmenu Cocoa: Do not process ampersands in menus twice. 2014-05-21 13:59:18 +02:00
qmenubar expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
qplaintextedit QPlainTextEdit: Fix crash on complex undo w/full width selection 2014-09-30 10:21:39 +02:00
qprogressbar
qpushbutton Fix QPushButton autotest 2014-04-03 11:07:07 +02:00
qradiobutton
qscrollarea
qscrollbar Respect scrollbar position setting on Mac 2014-03-20 19:01:53 +01:00
qsizegrip QSizeGrip: use a QPointer to the tracked TLW 2014-09-15 20:50:50 +02:00
qslider
qspinbox Merge remote-tracking branch 'origin/stable' into dev 2013-12-16 16:59:33 +01:00
qsplitter QSplitter: Exclude top level widgets from child event handling. 2014-07-15 11:24:38 +02:00
qstackedwidget
qstatusbar Replace hard-coded qWait() by QTRY_COMPARE/VERIFY in widget tests. 2014-05-26 15:06:12 +02:00
qtabbar Restore Qt 4 behavior in default double click handler 2014-04-17 10:59:13 +02:00
qtabwidget Restore Qt 4 behavior in default double click handler 2014-04-17 10:59:13 +02:00
qtextbrowser
qtextedit QTextLayout: Fix visual cursor movement in some cases 2014-04-04 19:32:21 +02:00
qtoolbar
qtoolbox expand tabs and related whitespace fixes in *.{cpp,h,qdoc} 2014-01-13 22:46:50 +01:00
qtoolbutton QToolButton: properly reset the size hint when a menu is set on it 2014-09-16 22:42:47 +02:00
widgets.pro