summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews/qtreewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/itemviews/qtreewidget.cpp')
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index f72abd20ab..f098236d5c 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -614,7 +614,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
}
LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
- qStableSort(sorting.begin(), sorting.end(), compare);
+ std::stable_sort(sorting.begin(), sorting.end(), compare);
QModelIndexList oldPersistentIndexes;
QModelIndexList newPersistentIndexes;
@@ -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);
@@ -848,7 +854,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
// do the sorting
LessThan compare = (order == Qt::AscendingOrder ? &itemLessThan : &itemGreaterThan);
- qStableSort(sorting.begin(), sorting.end(), compare);
+ std::stable_sort(sorting.begin(), sorting.end(), compare);
QModelIndexList fromList;
QModelIndexList toList;