qt5base-lts/tests/auto/widgets/itemviews
David Faure 74a4d88e9a QAbstractItemModel: fix persistent index corruption when moving columns
QHeaderView creates persistent indexes in
_q_sectionsAboutToBeChanged(), called by the slot connected to
rowsAboutToBeMoved/columnsAboutToBeMoved.

In the case of rows, QAbstractItemModel emits the signal *before*
preparing to update persistent indexes in itemsAboutToBeMoved(),
so it can see the ones newly created by QHeaderView, all is well.

In the case of columns, the emit was done *after* calling
itemsAboutToBeMoved(), so the additional persistent indexes created by
QHeaderView were ignored, and in endMoveRows() we could end up with:
ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: "persistent model indexes corrupted"

This bug has been there since the very beginning of beginMoveColumns(),
but was undetected because moving columns in a model is pretty rare
(in my case there's a QTransposeProxyModel that turns columns into
rows in the underlying model, and a proxy that handles dropMimeData...)

Pick-to: 6.3 6.2 5.15
Change-Id: I74bad137594019a04c2a19c2abb351ff3065c25a
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-28 09:43:37 +01:00
..
qabstractitemview Repair tst_qabstractitemview in case of no cursor 2022-02-16 21:09:59 +01:00
qcolumnview Remove the qmake project files 2021-01-07 15:32:28 +01:00
qdatawidgetmapper Remove the qmake project files 2021-01-07 15:32:28 +01:00
qfileiconprovider Verify that QFileIconProvider returns valid pixmaps 2021-02-23 15:34:05 +01:00
qheaderview QAbstractItemModel: fix persistent index corruption when moving columns 2022-02-28 09:43:37 +01:00
qitemdelegate Deprecate QContextMenuEvent and QMouseEvent ctors without globalPos 2022-02-05 17:18:35 +01:00
qitemeditorfactory Remove the qmake project files 2021-01-07 15:32:28 +01:00
qitemview Remove the qmake project files 2021-01-07 15:32:28 +01:00
qlistview QtBase: replace windows.h with qt_windows.h 2021-11-23 12:53:46 +08:00
qlistwidget emit layoutAboutToBeChanged timely 2021-07-20 21:27:27 +01:00
qtableview Repair some of tst_qtableview tests on Android 2022-02-22 17:22:59 +01:00
qtablewidget Select a single range of cells in QTableView, away from merged cells 2021-10-12 09:07:54 +02:00
qtreeview Repair tst_qtreeview on Android 2022-02-16 22:32:56 +01:00
qtreewidget emit layoutAboutToBeChanged timely 2021-07-20 21:27:27 +01:00
qtreewidgetitemiterator Remove the qmake project files 2021-01-07 15:32:28 +01:00
CMakeLists.txt CMake: Regenerate subdir test projects 2020-07-09 09:38:39 +02:00