aboutsummaryrefslogtreecommitdiffstats
path: root/cppgenerator.cpp
diff options
context:
space:
mode:
authorHugo Lima <hugo.lima@openbossa.org>2010-01-13 13:57:09 -0200
committerHugo Lima <hugo.lima@openbossa.org>2010-01-13 15:16:39 -0200
commitc06ceb1aab9b8199a75f9b9572a0556c8b9a6a97 (patch)
tree7fd766b2b4c469e865f1d8b38a6b0849d9355ff2 /cppgenerator.cpp
parent1bfff6f2f2549dd3a4e068e5bd767f72d8c7bd8b (diff)
Fix transfer ownership on return values.
Reviewed by Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'cppgenerator.cpp')
-rw-r--r--cppgenerator.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 136026bee..3f83f137e 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -1276,13 +1276,18 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
s << INDENT;
- if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::TargetLangOwnership)
- s << "SbkBaseWrapper_setOwnership(" << pyArgName << ", true";
- else if (wrappedClass->hasVirtualDestructor())
- s << "BindingManager::instance().transferOwnershipToCpp(" << pyArgName;
- else
- s << "BindingManager::instance().invalidateWrapper(" << pyArgName;
- s << ");" << endl;
+ if (arg_mod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::TargetLangOwnership) {
+ s << "SbkBaseWrapper_setOwnership(" << pyArgName << ", true);";
+ } else if (wrappedClass->hasVirtualDestructor()) {
+ if (arg_mod.index == 0) {
+ s << "SbkBaseWrapper_setOwnership(py_result, 0);";
+ } else {
+ s << "BindingManager::instance().transferOwnershipToCpp(" << pyArgName << ");";
+ }
+ } else {
+ s << "BindingManager::instance().invalidateWrapper(" << pyArgName << ");";
+ }
+ s << endl;
}
}
}