From a571f361a292973261054c722f3dad6862ec7bfe Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Tue, 16 Jul 2013 15:55:14 +0000 Subject: [PATCH] merged fixes from RC_0_16 --- ChangeLog | 1 + bindings/python/src/torrent_handle.cpp | 21 +++++++++++++-------- include/libtorrent/torrent.hpp | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6cedc794d..daf255ed3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * python binding fix issue where torrent_info objects where destructing when their torrents were deleted * added missing field to scrape_failed_alert in python bindings * GCC 4.8 fix * fix proxy failure semantics with regards to anonymous mode diff --git a/bindings/python/src/torrent_handle.cpp b/bindings/python/src/torrent_handle.cpp index 314e8eddc..ce336d1c8 100644 --- a/bindings/python/src/torrent_handle.cpp +++ b/bindings/python/src/torrent_handle.cpp @@ -175,7 +175,7 @@ void file_prioritity1(torrent_handle& h, int index, int prio) void dict_to_announce_entry(dict d, announce_entry& ae) { - ae.url = extract(d["url"]); + ae.url = extract(d["url"]); if (d.has_key("tier")) ae.tier = extract(d["tier"]); if (d.has_key("fail_limit")) @@ -210,8 +210,8 @@ void replace_trackers(torrent_handle& h, object trackers) dict d; d = extract(object(entry)); announce_entry ae; - dict_to_announce_entry(d, ae); - result.push_back(ae); + dict_to_announce_entry(d, ae); + result.push_back(ae); } } @@ -221,9 +221,9 @@ void replace_trackers(torrent_handle& h, object trackers) void add_tracker(torrent_handle& h, dict d) { - announce_entry ae; - dict_to_announce_entry(d, ae); - h.add_tracker(ae); + announce_entry ae; + dict_to_announce_entry(d, ae); + h.add_tracker(ae); } list trackers(torrent_handle& h) @@ -289,7 +289,7 @@ list get_download_queue(torrent_handle& handle) void set_metadata(torrent_handle& handle, std::string const& buf) { - handle.set_metadata(buf.c_str(), buf.size()); + handle.set_metadata(buf.c_str(), buf.size()); } namespace @@ -300,6 +300,11 @@ namespace } } +boost::intrusive_ptr get_torrent_info(torrent_handle const& h) +{ + return boost::intrusive_ptr(&h.get_torrent_info()); +} + void force_reannounce(torrent_handle& th, int s) { th.force_reannounce(boost::posix_time::seconds(s)); @@ -371,7 +376,7 @@ void bind_torrent_handle() .def("add_http_seed", _(&torrent_handle::add_http_seed)) .def("remove_http_seed", _(&torrent_handle::remove_http_seed)) .def("http_seeds", http_seeds) - .def("get_torrent_info", _(&torrent_handle::get_torrent_info), return_internal_reference<>()) + .def("get_torrent_info", get_torrent_info) .def("set_metadata", set_metadata) .def("is_valid", _(&torrent_handle::is_valid)) .def("pause", _(&torrent_handle::pause), arg("flags") = 0) diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index acdd68405..e20a819fa 100644 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -123,7 +123,7 @@ namespace libtorrent #endif sha1_hash const& info_hash() const - { return m_torrent_file->info_hash(); } + { return m_torrent_file ? m_torrent_file->info_hash() : sha1_hash(); } // starts the announce timer void start();