Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
5.8.0
-
None
-
be0a221ae491b8426b3a4cdf0d5863701e922c1f
Description
Description
--------------
The QItemSelection lose its selection if it contains a selected index whose column is > 0 (i.e. index(0,1) and the QItemSelection::Model emits the layoutChanged signal.
How to reproduce
-----------------------
1) Create a project with a TableModel and a QTableView
2) Enable QTableView sorting
3) Select index(0,1) in the view
4) Sort the indexes by first column
5) The selection is lost but the current index remains
Debug Session
----------------------
This is caused by line
https://code.woboq.org/qt5/qtbase/src/corelib/itemmodels/qitemselectionmodel.cpp.html#926
result.append(QItemSelectionRange(tl, br.sibling(br.row(), length - 1)));
In fact:
- tl is index(0,1)
- br is index(0,1) too given that we selected a single index
- length is 1
but that range is invalid because the QItemSelectionRange is
{index(0,1), index(0,0)}and the TopLeft.left() is > BottomRight.right()