diff options
| author | Peter Penz <[email protected]> | 2012-05-17 11:14:04 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-05-17 11:16:19 +0200 |
| commit | ff6e4341c5ce58b44af32db27ee3cec7057c8ce7 (patch) | |
| tree | b7e1b2c4b838c67650518407cdc9bdb98a19d371 /src | |
| parent | 855560dd32e8f275a7a3e6eb4cc7c2e1d262a47b (diff) | |
Fix crash related to group-headers
If multiple ranges are inserted or removed, the updating of
the group-headers may only be done after _all_ ranges have been
inserted/removed and not after each individual range. Otherwise
the layouter-cache is not in a consistent state yet.
Diffstat (limited to 'src')
| -rw-r--r-- | src/kitemviews/kitemlistview.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp index d1d8749aa..0f31cb5a1 100644 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@ -922,13 +922,6 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges) } } - // In case if items of the same group have been inserted before an item that - // currently represents the first item of the group, the group header of - // this item must be removed. - if (m_grouped && index + count < m_model->count()) { - updateGroupHeaderForWidget(m_visibleItems.value(index + count)); - } - if (m_model->count() == count && m_activeTransactions == 0) { // Check whether a scrollbar is required to show the inserted items. In this case // the size of the layouter will be decreased before calling doLayout(): This prevents @@ -967,9 +960,17 @@ void KItemListView::slotItemsInserted(const KItemRangeList& itemRanges) #endif m_endTransactionAnimationHint = NoAnimation; endTransaction(); + updateSiblingsInformation(); } + if (m_grouped && (hasMultipleRanges || itemRanges.first().count < m_model->count())) { + // In case if items of the same group have been inserted before an item that + // currently represents the first item of the group, the group header of + // this item must be removed. + updateVisibleGroupHeaders(); + } + if (useAlternateBackgrounds()) { updateAlternateBackgrounds(); } @@ -1056,12 +1057,6 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges) } } - // In case if the first item of a group has been removed, the group header - // must be applied to the next visible item. - if (m_grouped && index < m_model->count()) { - updateGroupHeaderForWidget(m_visibleItems.value(index)); - } - if (!hasMultipleRanges) { // The decrease-layout-size optimization in KItemListView::slotItemsInserted() // assumes an updated geometry. If items are removed during an active transaction, @@ -1091,6 +1086,12 @@ void KItemListView::slotItemsRemoved(const KItemRangeList& itemRanges) updateSiblingsInformation(); } + if (m_grouped && (hasMultipleRanges || m_model->count() > 0)) { + // In case if the first item of a group has been removed, the group header + // must be applied to the next visible item. + updateVisibleGroupHeaders(); + } + if (useAlternateBackgrounds()) { updateAlternateBackgrounds(); } |
