QTreeWidget - iterator fix in QTreeModel::ensureSorted
We can not trust the iterator when we do erase. This patch makes an index while we do a takeAt and then we restore the iterator from that index. This both ensures that we can merge an iterator check and ensures consistent behavior. Change-Id: Icbe67051cb055d24541475e826109212eba9dd30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6347afbfdd
commit
7ddf1b14ec
@ -623,7 +623,13 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
int oldRow = sorting.at(i).second;
|
||||
|
||||
int tmpitepos = lit - lst.begin();
|
||||
QTreeWidgetItem *item = lst.takeAt(oldRow);
|
||||
if (tmpitepos > lst.size())
|
||||
--tmpitepos;
|
||||
lit = lst.begin() + tmpitepos;
|
||||
|
||||
lit = sortedInsertionIterator(lit, lst.end(), order, item);
|
||||
int newRow = qMax(lit - lst.begin(), 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user