diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-10 08:17:28 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-10 08:17:28 (GMT) |
commit | 2298b8e670eb8620f3887854a8c018126c9b6e7f (patch) | |
tree | c5919fa9c6f058c0a6fd2f45c742a6f40b5d024a /src/declarative/graphicsitems | |
parent | 77b65788ab99b9f8e53d8b4149948a5012df110f (diff) | |
download | Qt-2298b8e670eb8620f3887854a8c018126c9b6e7f.zip Qt-2298b8e670eb8620f3887854a8c018126c9b6e7f.tar.gz Qt-2298b8e670eb8620f3887854a8c018126c9b6e7f.tar.bz2 |
Make sure item release isn't deferred indefinately
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 11 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview.cpp | 14 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index afc2e15..83911c0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -158,7 +158,8 @@ public: , moveReason(Other), buffer(0), highlightXAnimator(0), highlightYAnimator(0) , bufferMode(NoBuffer) , ownModel(false), wrap(false), autoHighlight(true) - , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) {} + , fixCurrentVisibility(false), lazyRelease(false), layoutScheduled(false) + , deferredRelease(false) {} void init(); void clear(); @@ -337,6 +338,7 @@ public: bool fixCurrentVisibility : 1; bool lazyRelease : 1; bool layoutScheduled : 1; + bool deferredRelease : 1; }; void QmlGraphicsGridViewPrivate::init() @@ -484,7 +486,7 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) break; } - if (!lazyRelease || !changed) { // avoid destroying items in the same frame that we create + if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endRowPos() < bufferFrom - rowSize()*(item->colPos()/colSize()+1)/(columns+1)) { @@ -507,6 +509,9 @@ void QmlGraphicsGridViewPrivate::refill(qreal from, qreal to, bool doBuffer) releaseItem(item); changed = true; } + deferredRelease = false; + } else { + deferredRelease = true; } if (changed) { if (flow == QmlGraphicsGridView::LeftToRight) @@ -1416,7 +1421,7 @@ void QmlGraphicsGridView::componentComplete() void QmlGraphicsGridView::trackedPositionChanged() { Q_D(QmlGraphicsGridView); - if (!d->trackedItem) + if (!d->trackedItem || !d->currentItem) return; if (!isFlicking() && !d->moving && d->moveReason == QmlGraphicsGridViewPrivate::SetIndex) { const qreal viewPos = d->position(); diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index a7a37e5..7037f11 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -223,7 +223,7 @@ public: , bufferMode(NoBuffer) , ownModel(false), wrap(false), autoHighlight(true), haveHighlightRange(false) , correctFlick(true), inFlickCorrection(false), lazyRelease(false) - , minExtentDirty(true), maxExtentDirty(true) + , deferredRelease(false), minExtentDirty(true), maxExtentDirty(true) {} void init(); @@ -448,11 +448,9 @@ public: void updateViewport() { Q_Q(QmlGraphicsListView); if (orient == QmlGraphicsListView::Vertical) { - qreal vpHeight = -q->maxYExtent() + q->minYExtent() + q->height(); - q->setViewportHeight(vpHeight); + q->setViewportHeight(endPosition() - startPosition() + 1); } else { - qreal vpWidth = -q->maxXExtent() + q->minXExtent() + q->width(); - q->setViewportWidth(qMin(vpWidth, q->width())); + q->setViewportWidth(endPosition() - startPosition() + 1); } } @@ -544,6 +542,7 @@ public: bool correctFlick : 1; bool inFlickCorrection : 1; bool lazyRelease : 1; + bool deferredRelease : 1; mutable bool minExtentDirty : 1; mutable bool maxExtentDirty : 1; }; @@ -701,7 +700,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to, bool doBuffer) break; } - if (!lazyRelease || !changed) { // avoid destroying items in the same frame that we create + if (!lazyRelease || !changed || deferredRelease) { // avoid destroying items in the same frame that we create while (visibleItems.count() > 1 && (item = visibleItems.first()) && item->endPosition() < bufferFrom) { if (item->attached->delayRemove()) break; @@ -720,6 +719,9 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to, bool doBuffer) releaseItem(item); changed = true; } + deferredRelease = false; + } else { + deferredRelease = true; } if (changed) { minExtentDirty = true; |