diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-08-02 06:44:33 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-08-02 06:44:33 (GMT) |
commit | a07bae9717168c9605662e117132e16b5f2b2f9d (patch) | |
tree | 13b0846025c89a4b02d40485f90e9dfcc62150f0 /src/declarative/graphicsitems | |
parent | b0607f042af4ebad70ca821036bd3f2beff3955e (diff) | |
download | Qt-a07bae9717168c9605662e117132e16b5f2b2f9d.zip Qt-a07bae9717168c9605662e117132e16b5f2b2f9d.tar.gz Qt-a07bae9717168c9605662e117132e16b5f2b2f9d.tar.bz2 |
Ensure currentItem is released when the delegate changes
Otherwise a new delegate isn't created for the currentItem.
GridView didn't release any item. It is now equivalent to LsitView.
Task-number: QTBUG-12548
Reviewed-by: Bea Lam
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativegridview.cpp | 5 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativelistview.cpp | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index f02ef6b..68a4c64 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1278,6 +1278,11 @@ void QDeclarativeGridView::setDelegate(QDeclarativeComponent *delegate) if (QDeclarativeVisualDataModel *dataModel = qobject_cast<QDeclarativeVisualDataModel*>(d->model)) { dataModel->setDelegate(delegate); if (isComponentComplete()) { + for (int i = 0; i < d->visibleItems.count(); ++i) + d->releaseItem(d->visibleItems.at(i)); + d->visibleItems.clear(); + d->releaseItem(d->currentItem); + d->currentItem = 0; refill(); d->moveReason = QDeclarativeGridViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 256948a..82b3e1c 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1620,6 +1620,8 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) for (int i = 0; i < d->visibleItems.count(); ++i) d->releaseItem(d->visibleItems.at(i)); d->visibleItems.clear(); + d->releaseItem(d->currentItem); + d->currentItem = 0; refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); |