From 6a3d99ff1747f725fbdfba0353eb74175156fab8 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 16 Apr 2013 14:26:38 +0200 Subject: Prevent crash when moving elements of a ListView's ListModel. QDeclarativeListView::itemsMoved wasn't checking if its list of visible items was empty before accessing its first element. Task-number: QTBUG-26836 Change-Id: I5ed42889a55026f19e44e44d14080a61fff63b59 Reviewed-by: Sean Harmer Reviewed-by: Gunnar Sletta --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/declarative') diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 38b3c4d9ac..0177597c4a 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -3578,7 +3578,8 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) } // Ensure we don't cause an ugly list scroll. - d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); + if (!d->visibleItems.isEmpty()) + d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); d->updateSections(); d->layout(); -- cgit v1.2.1