summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-10-27 05:22:45 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-10-27 05:24:36 (GMT)
commitcc084a1a05c53035bf401aed2e08e3c30a75e509 (patch)
tree2c56390988dbcdcd5fdf0d4d0f85a1d82e3eaf3d /src/declarative
parentc14af1c242ea3b268a4b6a5df62869bfd0efb6c4 (diff)
downloadQt-cc084a1a05c53035bf401aed2e08e3c30a75e509.zip
Qt-cc084a1a05c53035bf401aed2e08e3c30a75e509.tar.gz
Qt-cc084a1a05c53035bf401aed2e08e3c30a75e509.tar.bz2
Adding items to a view with no delegate crashes.
If there is no delegate then clear state and return. Change-Id: I786b9bc4018706797056fbd1ad25d25663102707 Task-number: QTBUG-22379 Reviewed-by: Andrew den Exter
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/graphicsitems/qdeclarativegridview.cpp10
-rw-r--r--src/declarative/graphicsitems/qdeclarativelistview.cpp15
2 files changed, 25 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp
index 29c714d..feca6b5 100644
--- a/src/declarative/graphicsitems/qdeclarativegridview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp
@@ -2852,6 +2852,11 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count)
addedVisible = true;
}
FxGridItem *item = d->createItem(modelIndex + i);
+ if (!item) {
+ // broken or no delegate
+ d->clear();
+ return;
+ }
d->visibleItems.insert(index, item);
item->setPosition(colPos, rowPos);
added.append(item);
@@ -3042,6 +3047,11 @@ void QDeclarativeGridView::itemsMoved(int from, int to, int count)
FxGridItem *movedItem = moved.take(item->index);
if (!movedItem)
movedItem = d->createItem(item->index);
+ if (!movedItem) {
+ // broken or no delegate
+ d->clear();
+ return;
+ }
it = d->visibleItems.insert(it, movedItem);
if (it == d->visibleItems.begin() && firstItem)
movedItem->setPosition(firstItem->colPos(), firstItem->rowPos());
diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp
index 920b6ae..37c34dc 100644
--- a/src/declarative/graphicsitems/qdeclarativelistview.cpp
+++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp
@@ -3283,6 +3283,11 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
addedVisible = true;
}
FxListItem *item = d->createItem(modelIndex + i);
+ if (!item) {
+ // broken or no delegate
+ d->clear();
+ return;
+ }
d->visibleItems.insert(insertionIdx, item);
pos -= item->size() + d->spacing;
item->setPosition(pos);
@@ -3313,6 +3318,11 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count)
addedVisible = true;
}
FxListItem *item = d->createItem(modelIndex + i);
+ if (!item) {
+ // broken or no delegate
+ d->clear();
+ return;
+ }
d->visibleItems.insert(index, item);
item->setPosition(pos);
added.append(item);
@@ -3516,6 +3526,11 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count)
FxListItem *movedItem = moved.take(item->index);
if (!movedItem)
movedItem = d->createItem(item->index);
+ if (!movedItem) {
+ // broken or no delegate
+ d->clear();
+ return;
+ }
if (item->index <= firstVisible->index)
moveBy -= movedItem->size();
it = d->visibleItems.insert(it, movedItem);