diff options
| author | Frank Reininghaus <[email protected]> | 2012-10-27 09:48:51 +0200 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-10-27 09:48:51 +0200 |
| commit | 37a54c053e4712ffc9fc39fb0d8809f70c6bf9a9 (patch) | |
| tree | 0cff652d2836c97b9339fcd5e94165783a8b9851 /src/kitemviews | |
| parent | 282f5cb869696a87c14da8e80ed7096b9055cd12 (diff) | |
Workaround for failed comparison of items in KFileItemModelRolesUpdater
The real fix is in the KDE/4.10 branch of kdelibs
(commit b8f64ca3f4b6311519c21046031d66d9d0a570c6). We work around the
problem that the KFileItem that a preview has been requested for is
different from the KFileItems in the sets m_pendingVisibleItems and
m_pendingInvisibleItems by refreshing those sets when we detect that
the bug has been triggered.
BUG: 304986
FIXED-IN: 4.9.3
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemmodelrolesupdater.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index f5de6b6dd..57beb9d2f 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -439,9 +439,22 @@ void KFileItemModelRolesUpdater::slotSortRoleChanged(const QByteArray& current, void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPixmap& pixmap) { + const int oldNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); + m_pendingVisibleItems.remove(item); m_pendingInvisibleItems.remove(item); + const int newNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); + + if (oldNumberOfPendingItems == newNumberOfPendingItems) { + // 'item' could not be removed from either of the sets. It looks like + // we have hit bug 304986. Replace the items in the sets by the items + // in the model to work around the problem. + // NOTE: This workaround is not needed any more in KDE 4.10. + m_pendingVisibleItems = sortedItems(m_pendingVisibleItems).toSet(); + m_pendingInvisibleItems = sortedItems(m_pendingInvisibleItems).toSet(); + } + const int index = m_model->index(item); if (index < 0) { return; @@ -499,9 +512,22 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item) { + const int oldNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); + m_pendingVisibleItems.remove(item); m_pendingInvisibleItems.remove(item); + const int newNumberOfPendingItems = m_pendingVisibleItems.count() + m_pendingInvisibleItems.count(); + + if (oldNumberOfPendingItems == newNumberOfPendingItems) { + // 'item' could not be removed from either of the sets. It looks like + // we have hit bug 304986. Replace the items in the sets by the items + // in the model to work around the problem. + // NOTE: This workaround is not needed any more in KDE 4.10. + m_pendingVisibleItems = sortedItems(m_pendingVisibleItems).toSet(); + m_pendingInvisibleItems = sortedItems(m_pendingInvisibleItems).toSet(); + } + const bool clearPreviews = m_clearPreviews; m_clearPreviews = true; applyResolvedRoles(item, ResolveAll); |
