aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontainer.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2019-07-04 13:35:55 +0200
committerLiang Qi <liang.qi@qt.io>2019-07-04 13:35:55 +0200
commit5211cf2843af606b912e9130d44ee6c82eeb40b0 (patch)
treed2a90e480d497edc3bbac367bf974ec93076e409 /src/quicktemplates2/qquickcontainer.cpp
parent13bdd61c6597586f62558ca337c193ce03db26cc (diff)
parentce7c431fb23157fa5125d1102a594de045818a72 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts: .qmake.conf tests/auto/accessibility/tst_accessibility.cpp Change-Id: I0bc187e2a8edb4e357c1bf114dd9b1977d5c1e45
Diffstat (limited to 'src/quicktemplates2/qquickcontainer.cpp')
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 2c357f82..609c2079 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -294,8 +294,9 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
updatingCurrent = true;
+ int count = contentModel->count();
bool currentChanged = false;
- if (index == currentIndex) {
+ if (index == currentIndex && (index != 0 || count == 1)) {
q->setCurrentIndex(currentIndex - 1);
} else if (index < currentIndex) {
--currentIndex;
@@ -305,10 +306,10 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
item->setParentItem(nullptr);
contentModel->remove(index);
+ --count;
q->itemRemoved(index, item);
- int count = contentModel->count();
for (int i = index; i < count; ++i)
q->itemMoved(i, itemAt(i));