diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 2766bdef9..1993f1df7 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -1578,7 +1578,10 @@ int main(int argc, char* argv[]) std::string event_string; ::print_alert(*i, event_string); - ::handle_alert(ses, *i, files, non_files); + TORRENT_TRY + { + ::handle_alert(ses, *i, files, non_files); + } TORRENT_CATCH(std::exception& e) {} events.push_back(event_string); if (events.size() >= 20) events.pop_front(); diff --git a/src/session.cpp b/src/session.cpp index ce36a21b6..ccc62127e 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -685,6 +685,12 @@ namespace libtorrent void session::remove_torrent(const torrent_handle& h, int options) { + if (!h.is_valid()) +#ifdef BOOST_NO_EXCEPTIONS + return; +#else + throw_invalid_handle(); +#endif TORRENT_ASYNC_CALL2(remove_torrent, h, options); } diff --git a/src/session_impl.cpp b/src/session_impl.cpp index f64ef3527..10775d0d8 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -4232,12 +4232,8 @@ namespace aux { void session_impl::remove_torrent(const torrent_handle& h, int options) { boost::shared_ptr tptr = h.m_torrent.lock(); - if (!tptr) -#ifdef BOOST_NO_EXCEPTIONS - return; -#else - throw_invalid_handle(); -#endif + if (!tptr) return; + remove_torrent_impl(tptr, options); if (m_alerts.should_post())