Skip to content

Commit

Permalink
Download improvements
Browse files Browse the repository at this point in the history
- Use UUID as key in map to help improve access times
- Fix issues with removed/hidden downloads leaving empty rows
- Fix crashes caused by having an empty download list
  • Loading branch information
Silarn committed Oct 22, 2023
1 parent 02004a2 commit bb0ebf2
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 97 deletions.
6 changes: 4 additions & 2 deletions src/downloadlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,11 @@ void DownloadList::downloadRemoved(QUuid moId)
log::debug("Download List - Removing Item: {}", downloadIndex);
emit beginRemoveRows(QModelIndex(), downloadIndex, downloadIndex);
m_downloadIndexCache.erase(downloadListItem->moId.toString());
m_downloadListItems.removeAt(downloadListItem - m_downloadListItems.begin());
m_downloadListItems.removeAt(downloadIndex);
for (auto item : m_downloadListItems) {
m_downloadIndexCache[item.moId.toString()] = m_downloadListItems.indexOf(item);
}
emit endRemoveRows();

log::debug("Download List Size (after remove): {}", m_downloadListItems.size());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/downloadlistitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct DownloadListItem
~DownloadListItem() = default;
DownloadListItem(const DownloadListItem&) = default;
DownloadListItem& operator=(const DownloadListItem&) = default;
auto operator<=>(const DownloadListItem&) const = default;

int pendingIndex{-1};
bool isPending{false};
Expand Down
Loading

0 comments on commit bb0ebf2

Please sign in to comment.