diff --git a/src/library/tabledelegates/coverartdelegate.cpp b/src/library/tabledelegates/coverartdelegate.cpp index df7417a522e..e9f84493eba 100644 --- a/src/library/tabledelegates/coverartdelegate.cpp +++ b/src/library/tabledelegates/coverartdelegate.cpp @@ -178,16 +178,9 @@ void CoverArtDelegate::paintItem( } void CoverArtDelegate::cleanCacheMissRows() const { - auto it = m_cacheMissRows.begin(); - while (it != m_cacheMissRows.end()) { - const QModelIndex index = m_pTableView->model()->index(*it, m_column); + decltype(m_cacheMissRows)::erase_if(m_cacheMissRows, [this](int row) { + const QModelIndex index = m_pTableView->model()->index(row, m_column); const QRect rect = m_pTableView->visualRect(index); - if (!rect.intersects(m_pTableView->rect())) { - // Cover image row is no longer shown. We keep the set - // small which likely reuses the allocatd memory later - it = m_cacheMissRows.erase(it); - } else { - ++it; - } - } + return !rect.intersects(m_pTableView->rect()); + }); }