diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-15 03:03:05 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-12-15 03:03:05 +0100 |
commit | d8f3fb7438bbbe0b807b124f26fe3204ce50c1ec (patch) | |
tree | 0a08a13c7e6aeed42fa26f2825ddd317a1f2470d /src/controls/Private/qquicktreemodeladaptor.cpp | |
parent | 9c3f0688a549c0e57c08d4715b277e05e35849d9 (diff) | |
parent | 5e2dfd09b3ace43c2f3dc75c56933c7c723b50fb (diff) | |
download | qtquickcontrols-d8f3fb7438bbbe0b807b124f26fe3204ce50c1ec.tar.gz |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: Ia98756445b50decfd50f6bdeb94a004fa90d3a05
Diffstat (limited to 'src/controls/Private/qquicktreemodeladaptor.cpp')
-rw-r--r-- | src/controls/Private/qquicktreemodeladaptor.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index 495abc9c..287b388f 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -283,6 +283,8 @@ QItemSelection QQuickTreeModelAdaptor1::selectionForRowRange(const QModelIndex return QItemSelection(); return QItemSelection(toIndex, toIndex); } + + to = qMax(to, 0); if (from > to) qSwap(from, to); @@ -360,8 +362,15 @@ void QQuickTreeModelAdaptor1::showModelChildItems(const TreeItem &parentItem, in if (start == 0) { startIdx = rowIdx; } else { - const QModelIndex &prevSiblingIdx = m_model->index(start - 1, 0, parentIndex); - startIdx = lastChildIndex(prevSiblingIdx) + 1; + // Prefer to insert before next sibling instead of after last child of previous, as + // the latter is potentially buggy, see QTBUG-66062 + const QModelIndex &nextSiblingIdx = m_model->index(end + 1, 0, parentIndex); + if (nextSiblingIdx.isValid()) { + startIdx = itemIndex(nextSiblingIdx); + } else { + const QModelIndex &prevSiblingIdx = m_model->index(start - 1, 0, parentIndex); + startIdx = lastChildIndex(prevSiblingIdx) + 1; + } } int rowDepth = rowIdx == 0 ? 0 : parentItem.depth + 1; |