merged python binding fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-07-17 14:27:02 +00:00
parent 77710e4ac0
commit f10bedf035
2 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include <boost/python.hpp> #include <boost/python.hpp>
#include <libtorrent/alert.hpp> #include <libtorrent/alert.hpp>
#include <libtorrent/alert_types.hpp> #include <libtorrent/alert_types.hpp>
#include <memory>
using namespace boost::python; using namespace boost::python;
using namespace libtorrent; using namespace libtorrent;
@ -93,7 +94,7 @@ void bind_alert()
using boost::noncopyable; using boost::noncopyable;
{ {
scope alert_scope = class_<alert, noncopyable>("alert", no_init) scope alert_scope = class_<alert, boost::shared_ptr<alert>, noncopyable >("alert", no_init)
.def("message", &alert::message) .def("message", &alert::message)
.def("what", &alert::what) .def("what", &alert::what)
.def("category", &alert::category) .def("category", &alert::category)

View File

@ -475,6 +475,17 @@ namespace
return e; return e;
} }
object pop_alert(session& ses)
{
std::auto_ptr<alert> a;
{
allow_threading_guard guard;
a = ses.pop_alert();
}
return object(boost::shared_ptr<alert>(a.release()));
}
list pop_alerts(session& ses) list pop_alerts(session& ses)
{ {
std::deque<alert*> alerts; std::deque<alert*> alerts;
@ -487,8 +498,7 @@ namespace
for (std::deque<alert*>::iterator i = alerts.begin() for (std::deque<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i) , end(alerts.end()); i != end; ++i)
{ {
std::auto_ptr<alert> ptr(*i); ret.append(boost::shared_ptr<alert>(*i));
ret.append(ptr);
} }
return ret; return ret;
} }
@ -722,7 +732,7 @@ void bind_session()
.def("set_alert_queue_size_limit", allow_threads(&session::set_alert_queue_size_limit)) .def("set_alert_queue_size_limit", allow_threads(&session::set_alert_queue_size_limit))
#endif #endif
.def("set_alert_mask", allow_threads(&session::set_alert_mask)) .def("set_alert_mask", allow_threads(&session::set_alert_mask))
.def("pop_alert", allow_threads(&session::pop_alert)) .def("pop_alert", &pop_alert)
.def("pop_alerts", &pop_alerts) .def("pop_alerts", &pop_alerts)
.def("wait_for_alert", &wait_for_alert, return_internal_reference<>()) .def("wait_for_alert", &wait_for_alert, return_internal_reference<>())
.def("add_extension", &add_extension) .def("add_extension", &add_extension)