aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-02-02 19:04:16 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:13:53 -0300
commite78bd2efe4063d522effaaf6a6dc737fe8da8b79 (patch)
tree88c2d7b07bcf236bf936c08373032bf937b60590
parent0c49645f7fee72c92d2f25f18510d75811d7289a (diff)
Don't write return heuristic when there's a parent tag with the returned object involved.
Reviewer: Renato Araújo <renato.filho@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 84a61f160..3d33fae13 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2198,6 +2198,10 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
}
}
+ // If there's already a setParent(return, me), don't use the return heuristic!
+ if (func->argumentOwner(func->ownerClass(), -1).index == 0)
+ hasReturnPolicy = true;
+
if (!ownership_mods.isEmpty()) {
s << endl << INDENT << "// Ownership transferences." << endl;
foreach (ArgumentModification arg_mod, ownership_mods) {
@@ -2208,7 +2212,7 @@ void CppGenerator::writeMethodCall(QTextStream& s, const AbstractMetaFunction* f
break;
}
- if (arg_mod.index == 0)
+ if (arg_mod.index == 0 || arg_mod.owner.index == 0)
hasReturnPolicy = true;
// The default ownership does nothing. This is useful to avoid automatic heuristically
@@ -3870,13 +3874,9 @@ bool CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
childVariable = usePyArgs ? "pyargs["+QString::number(childIndex-1)+"]" : "arg";
s << INDENT << "Shiboken::Object::setParent(" << parentVariable << ", " << childVariable << ");\n";
-
return true;
}
- if (argIndex == 0 && useHeuristicPolicy)
- writeReturnValueHeuristics(s, func);
-
return false;
}
@@ -3888,7 +3888,10 @@ void CppGenerator::writeParentChildManagement(QTextStream& s, const AbstractMeta
// 0 = self
// 1..n = func. args.
for (int i = -1; i <= numArgs; ++i)
- writeParentChildManagement(s, func, i, i == 0 ? useHeuristicForReturn : true);
+ writeParentChildManagement(s, func, i, useHeuristicForReturn);
+
+ if (useHeuristicForReturn)
+ writeReturnValueHeuristics(s, func);
}
void CppGenerator::writeReturnValueHeuristics(QTextStream& s, const AbstractMetaFunction* func, const QString& self)