Skip to content

Commit

Permalink
Check file count before refreshing widget
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr committed Oct 24, 2019
1 parent a0d3d40 commit 6a3deb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/picotorrent/torrentdetails/torrentfileswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ TorrentFilesWidget::TorrentFilesWidget()

void TorrentFilesWidget::clear()
{
m_currentFileCount = -1;
m_currentSelection = lt::info_hash_t();
m_filesModel->clearTree();
}
Expand All @@ -83,8 +84,8 @@ void TorrentFilesWidget::refresh(QList<pt::TorrentHandle*> const& torrents)
std::vector<int64_t> progress;
torrent->fileProgress(progress, lt::torrent_handle::piece_granularity);

// Only update progress if we have the same selection as previous
if (m_currentSelection == torrent->infoHash())
// Only update progress if we have the same selection and file count as previous
if (m_currentSelection == torrent->infoHash() && m_currentFileCount == ti->num_files())
{
m_filesModel->setProgress(progress);
}
Expand Down
1 change: 1 addition & 0 deletions src/picotorrent/torrentdetails/torrentfileswidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace pt
void showTorrentFileExplorer(QModelIndex const& index);

libtorrent::info_hash_t m_currentSelection;
int m_currentFileCount;
QTreeView* m_filesView;
FileStorageItemModel* m_filesModel;
QList<TorrentHandle*> m_torrents;
Expand Down

0 comments on commit 6a3deb3

Please sign in to comment.