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 <libtorrent/alert.hpp>
#include <libtorrent/alert_types.hpp>
#include <memory>
using namespace boost::python;
using namespace libtorrent;
@ -93,7 +94,7 @@ void bind_alert()
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("what", &alert::what)
.def("category", &alert::category)

View File

@ -475,6 +475,17 @@ namespace
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)
{
std::deque<alert*> alerts;
@ -487,8 +498,7 @@ namespace
for (std::deque<alert*>::iterator i = alerts.begin()
, end(alerts.end()); i != end; ++i)
{
std::auto_ptr<alert> ptr(*i);
ret.append(ptr);
ret.append(boost::shared_ptr<alert>(*i));
}
return ret;
}
@ -722,7 +732,7 @@ void bind_session()
.def("set_alert_queue_size_limit", allow_threads(&session::set_alert_queue_size_limit))
#endif
.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("wait_for_alert", &wait_for_alert, return_internal_reference<>())
.def("add_extension", &add_extension)