aboutsummaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
Diffstat (limited to 'generator')
-rw-r--r--generator/cppgenerator.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index ecd054c28..a5b06457e 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -743,6 +743,16 @@ void CppGenerator::writeVirtualMethodNative(QTextStream &s, const AbstractMetaFu
Indentation indentation(INDENT);
s << INDENT << "Shiboken::Object::invalidate(PyTuple_GET_ITEM(pyargs, ";
s << (argMod.index - 1) << "));" << endl;
+ } else if (argMod.ownerships.contains(TypeSystem::NativeCode)) {
+ if (argMod.index == 0 && argMod.ownerships[TypeSystem::NativeCode] == TypeSystem::CppOwnership) {
+ s << INDENT << "if (Shiboken::Object::checkType(" PYTHON_RETURN_VAR ")) {" << endl;
+ {
+ Indentation indent(INDENT);
+ s << INDENT << "Shiboken::Object::releaseOwnership(" PYTHON_RETURN_VAR ");" << endl;
+ s << INDENT << "Py_DECREF((PyObject*) " PYTHON_RETURN_VAR ");" << endl;
+ }
+ s << INDENT << '}' << endl;
+ }
}
}
}