From cd72238c25d9ba69269f60e6402990010cf055bb Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 11 Feb 2012 22:04:22 +0000 Subject: [PATCH] fix update issue in client_test --- examples/client_test.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index d5ecb4cc7..a2c5ec805 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -313,6 +313,7 @@ void update_filtered_torrents(boost::unordered_set& all_handles filtered_handles.push_back(&*i); } if (active_torrent >= int(filtered_handles.size())) active_torrent = filtered_handles.size() - 1; + else if (active_torrent == -1 && !filtered_handles.empty()) active_torrent = 0; std::sort(filtered_handles.begin(), filtered_handles.end(), &compare_torrent); } @@ -983,6 +984,7 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a } else if (state_update_alert* p = alert_cast(a)) { + bool need_filter_update = false; for (std::vector::iterator i = p->status.begin(); i != p->status.end(); ++i) { @@ -990,8 +992,14 @@ bool handle_alert(libtorrent::session& ses, libtorrent::alert* a // don't add new entries here, that's done in the handler // for add_torrent_alert if (j == all_handles.end()) continue; + if (j->state != i->state + || j->paused != i->paused + || j->auto_managed != i->auto_managed) + need_filter_update = true; ((torrent_status&)*j) = *i; } + if (need_filter_update) + update_filtered_torrents(all_handles, filtered_handles, counters); return true; }