Skip to content

Commit 8878e2c

Browse files
author
Martin Jones
committed
PathView offset out of sync with currentIndex when items are removed.
If the view is animating due to currentIndex change and items are removed the target offset must be recalculated. Change-Id: Iee105712488070c086a24561a49daf17bcf14076 Task-number: QTBUG-18825 Reviewed-by: Michael Brasser
1 parent 1083021 commit 8878e2c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/declarative/graphicsitems/qdeclarativepathview.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,8 @@ void QDeclarativePathView::itemsRemoved(int modelIndex, int count)
15251525
} else {
15261526
d->regenerate();
15271527
d->updateCurrent();
1528+
if (!d->flicking && !d->moving && d->haveHighlightRange && d->highlightRangeMode == QDeclarativePathView::StrictlyEnforceRange)
1529+
d->snapToCurrent();
15281530
}
15291531
if (changedOffset)
15301532
emit offsetChanged();

tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,16 @@ void tst_QDeclarativePathView::dataModel()
458458
model.removeItem(model.count()-1);
459459
QCOMPARE(pathview->currentIndex(), model.count()-1);
460460

461+
// QTBUG-18825
462+
// Confirm that the target offset is adjusted when removing items
463+
pathview->setCurrentIndex(model.count()-1);
464+
QTRY_COMPARE(pathview->offset(), 1.);
465+
pathview->setCurrentIndex(model.count()-5);
466+
model.removeItem(model.count()-1);
467+
model.removeItem(model.count()-1);
468+
model.removeItem(model.count()-1);
469+
QTRY_COMPARE(pathview->offset(), 2.);
470+
461471
delete canvas;
462472
}
463473

0 commit comments

Comments
 (0)