diff options
author | Martin Jones <[email protected]> | 2012-03-16 17:01:11 +1000 |
---|---|---|
committer | Qt by Nokia <[email protected]> | 2012-03-19 10:49:05 +0100 |
commit | f079f789c593996b0023afd6318d60d18ac66578 (patch) | |
tree | deefb71d52fa338ad812e376d356fcd1de44b303 /src/quick/items/qquicklistview.cpp | |
parent | cbe346a906f025af932b67c7c9672b109e218fa0 (diff) |
Ensure section header/footer are cleaned up.
If the model is cleared or replaced with an empty one,
the section headers should be released.
Change-Id: Ia2f070c312593743b2c5332a6c69facaf222ee6d
Reviewed-by: Bea Lam <[email protected]>
Diffstat (limited to 'src/quick/items/qquicklistview.cpp')
-rw-r--r-- | src/quick/items/qquicklistview.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp index 2590d4691f..9d9e3ae186 100644 --- a/src/quick/items/qquicklistview.cpp +++ b/src/quick/items/qquicklistview.cpp @@ -524,7 +524,9 @@ void QQuickListViewPrivate::clear() sectionCache[i] = 0; } visiblePos = 0; + releaseSectionItem(currentSectionItem); currentSectionItem = 0; + releaseSectionItem(nextSectionItem); nextSectionItem = 0; lastVisibleSection = QString(); QQuickItemViewPrivate::clear(); @@ -933,6 +935,8 @@ QQuickItem * QQuickListViewPrivate::getSectionItem(const QString §ion) void QQuickListViewPrivate::releaseSectionItem(QQuickItem *item) { + if (!item) + return; int i = 0; do { if (!sectionCache[i]) { @@ -970,7 +974,7 @@ void QQuickListViewPrivate::updateInlineSection(FxListItemSG *listItem) void QQuickListViewPrivate::updateStickySections() { - if (!sectionCriteria || visibleItems.isEmpty() + if (!sectionCriteria || (!sectionCriteria->labelPositioning() && !currentSectionItem && !nextSectionItem)) return; @@ -1006,7 +1010,7 @@ void QQuickListViewPrivate::updateStickySections() } // Current section header - if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart) { + if (sectionCriteria->labelPositioning() & QQuickViewSection::CurrentLabelAtStart && isValid() && visibleItems.count()) { if (!currentSectionItem) { currentSectionItem = getSectionItem(currentSection); } else if (currentStickySection != currentSection) { @@ -1039,7 +1043,7 @@ void QQuickListViewPrivate::updateStickySections() } // Next section footer - if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd) { + if (sectionCriteria->labelPositioning() & QQuickViewSection::NextLabelAtEnd && isValid() && visibleItems.count()) { if (!nextSectionItem) { nextSectionItem = getSectionItem(nextSection); } else if (nextStickySection != nextSection) { @@ -1077,7 +1081,7 @@ void QQuickListViewPrivate::updateSections() QQuickItemViewPrivate::updateSections(); - if (sectionCriteria && !visibleItems.isEmpty()) { + if (sectionCriteria && !visibleItems.isEmpty() && isValid()) { QString prevSection; if (visibleIndex > 0) prevSection = sectionAt(visibleIndex-1); |