add missing INCREF
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7814 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
02b14340c0
commit
18736f2cba
1 changed files with 10 additions and 3 deletions
|
|
@ -38,12 +38,16 @@ namespace swig {
|
||||||
class PyItem {
|
class PyItem {
|
||||||
PyObject *_obj;
|
PyObject *_obj;
|
||||||
public:
|
public:
|
||||||
|
PyItem() :_obj(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PyItem(const PyItem& item) : _obj(item._obj)
|
PyItem(const PyItem& item) : _obj(item._obj)
|
||||||
{
|
{
|
||||||
Py_XINCREF(_obj);
|
Py_XINCREF(_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyItem(PyObject *obj = 0) :_obj(obj)
|
PyItem(PyObject *obj) :_obj(obj)
|
||||||
{
|
{
|
||||||
Py_XINCREF(_obj);
|
Py_XINCREF(_obj);
|
||||||
}
|
}
|
||||||
|
|
@ -62,7 +66,7 @@ namespace swig {
|
||||||
|
|
||||||
~PyItem()
|
~PyItem()
|
||||||
{
|
{
|
||||||
Py_XDECREF(_obj);
|
if (_obj) Py_DECREF(_obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator PyObject *() const
|
operator PyObject *() const
|
||||||
|
|
@ -91,7 +95,9 @@ namespace swig {
|
||||||
template <> struct traits_from<PyItem> {
|
template <> struct traits_from<PyItem> {
|
||||||
typedef PyItem value_type;
|
typedef PyItem value_type;
|
||||||
static PyObject *from(const value_type& val) {
|
static PyObject *from(const value_type& val) {
|
||||||
return static_cast<PyObject *>(val);
|
PyObject *obj = static_cast<PyObject *>(val);
|
||||||
|
Py_XINCREF(obj);
|
||||||
|
return obj;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -158,6 +164,7 @@ namespace swig {
|
||||||
template <> struct traits_from<PyObject *> {
|
template <> struct traits_from<PyObject *> {
|
||||||
typedef PyObject * value_type;
|
typedef PyObject * value_type;
|
||||||
static PyObject *from(const value_type& val) {
|
static PyObject *from(const value_type& val) {
|
||||||
|
Py_XINCREF(val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue