summaryrefslogtreecommitdiffstats
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>2011-02-02 20:08:31 -0200
commit4b3a9db31192820e9d36cdd901be5c46dfa491e6 (patch)
tree802c5117c4137289f0136329c834f5105467a467
parentfe38422e866da80daa617bf94b0841f7a4457f09 (diff)
downloadshiboken-4b3a9db31192820e9d36cdd901be5c46dfa491e6.tar.gz
shiboken-4b3a9db31192820e9d36cdd901be5c46dfa491e6.tar.xz
shiboken-4b3a9db31192820e9d36cdd901be5c46dfa491e6.zip
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 ead961c2..853f2927 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -2196,6 +2196,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) {
@@ -2206,7 +2210,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
@@ -3872,13 +3876,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;
}
@@ -3890,7 +3890,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)