From a93ae86d8584fb5aedb27c48da1dd474a767c15b Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 26 Sep 2008 00:26:35 +0000 Subject: [PATCH] fixed bug in client_test when loading paused torrents --- examples/client_test.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 41d0951bd..9aae61ed6 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -617,7 +617,8 @@ void print_alert(libtorrent::alert const* a, std::ostream& os) g_log_file << "[" << time_now_string() << "] " << a->message() << std::endl; } -void handle_alert(libtorrent::session& ses, libtorrent::alert* a) +void handle_alert(libtorrent::session& ses, libtorrent::alert* a + , handles_t const& handles) { using namespace libtorrent; @@ -639,7 +640,9 @@ void handle_alert(libtorrent::session& ses, libtorrent::alert* a) , std::ios_base::binary); out.unsetf(std::ios_base::skipws); bencode(std::ostream_iterator(out), *p->resume_data); - if (h.is_paused() && !h.is_auto_managed()) ses.remove_torrent(h); + if (std::find_if(handles.begin(), handles.end() + , bind(&handles_t::value_type::second, _1) == h) == handles.end()) + ses.remove_torrent(h); } } } @@ -1218,7 +1221,7 @@ int main(int ac, char* av[]) std::stringstream event_string; ::print_alert(a.get(), event_string); - ::handle_alert(ses, a.get()); + ::handle_alert(ses, a.get(), handles); events.push_back(event_string.str()); if (events.size() >= 20) events.pop_front();