diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-07-29 18:08:42 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-07-29 19:28:18 -0300 |
commit | 9cba9a581d503accb04e517d982d734b7795139f (patch) | |
tree | d162d49eefc6b183d5d7c87b8b55fb673ec878fb /libshiboken/helper.h | |
parent | 6bb544de68ee3af71e27ccead37b10788f16dd8a (diff) |
Fixed reference leak on shiboken make tuple.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libshiboken/helper.h')
-rw-r--r-- | libshiboken/helper.h | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/libshiboken/helper.h b/libshiboken/helper.h index 3bda34a7b..a3a974b99 100644 --- a/libshiboken/helper.h +++ b/libshiboken/helper.h @@ -38,6 +38,7 @@ #include <Python.h> #include "shibokenmacros.h" #include "conversions.h" +#include "autodecref.h" namespace Shiboken { @@ -45,34 +46,35 @@ namespace Shiboken template<typename A, typename B> inline PyObject* makeTuple(const A& a, const B& b) { - return PyTuple_Pack(2, Converter<A>::toPython(a), Converter<B>::toPython(b)); + return PyTuple_Pack(2, AutoDecRef(Converter<A>::toPython(a)).object(), + AutoDecRef(Converter<B>::toPython(b)).object()); } template<typename A, typename B, typename C> inline PyObject* makeTuple(const A& a, const B& b, const C& c) { - return PyTuple_Pack(3, Converter<A>::toPython(a), - Converter<B>::toPython(b), - Converter<C>::toPython(c)); + return PyTuple_Pack(3, AutoDecRef(Converter<A>::toPython(a)).object(), + AutoDecRef(Converter<B>::toPython(b)).object(), + AutoDecRef(Converter<C>::toPython(c)).object()); } template<typename A, typename B, typename C, typename D> inline PyObject* makeTuple(const A& a, const B& b, const C& c, const D& d) { - return PyTuple_Pack(4, Converter<A>::toPython(a), - Converter<B>::toPython(b), - Converter<C>::toPython(c), - Converter<D>::toPython(d)); + return PyTuple_Pack(4, AutoDecRef(Converter<A>::toPython(a)).object(), + AutoDecRef(Converter<B>::toPython(b)).object(), + AutoDecRef(Converter<C>::toPython(c)).object(), + AutoDecRef(Converter<D>::toPython(d)).object()); } template<typename A, typename B, typename C, typename D, typename E> inline PyObject* makeTuple(const A& a, const B& b, const C& c, const D& d, const E& e) { - return PyTuple_Pack(5, Converter<A>::toPython(a), - Converter<B>::toPython(b), - Converter<C>::toPython(c), - Converter<D>::toPython(d), - Converter<E>::toPython(e)); + return PyTuple_Pack(5, AutoDecRef(Converter<A>::toPython(a)).object(), + AutoDecRef(Converter<B>::toPython(b)).object(), + AutoDecRef(Converter<C>::toPython(c)).object(), + AutoDecRef(Converter<D>::toPython(d)).object(), + AutoDecRef(Converter<E>::toPython(e)).object()); } /** |