Skip to content

Commit

Permalink
fixed ref-counting in test
Browse files Browse the repository at this point in the history
  • Loading branch information
florianlink committed Apr 22, 2015
1 parent 9619e24 commit bac28f6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/PythonQtTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,22 @@ public Q_SLOTS:
QColor getQColor4(const QVariant& color) { _called = true; return qvariant_cast<QColor>(color); }
QColor* getQColor5() { _called = true; static QColor c(1,2,3); return &c; }

PyObject* getPyObject(PyObject* obj) { _called = true; return obj; }
PyObject* getPyObjectFromVariant(const QVariant& val) { _called = true; return PythonQtObjectPtr(val); };
PyObject* getPyObject(PyObject* obj) {
_called = true;
// returned object needs to get an extra ref count!
Py_XINCREF(obj);
return obj;
}

PyObject* getPyObjectFromVariant(const QVariant& val) {
_called = true;
PythonQtObjectPtr value = val;
PyObject* obj = value.object();
// returned object needs to get an extra ref count!
Py_XINCREF(obj);
return obj;
};
QVariant getPyObjectFromVariant2(const QVariant& val) { _called = true; return val; };
// this does not yet work but is not required to work:
//PyObject* getPyObjectFromPtr(const PythonQtObjectPtr& val) { _called = true; return val; };

//! testing pointer passing
PythonQtTestSlotCallingHelper* getTestObject(PythonQtTestSlotCallingHelper* obj) { _called = true; return obj; }
Expand Down

0 comments on commit bac28f6

Please sign in to comment.