diff options
author | John Ehresman <jpe@wingware.com> | 2012-06-07 20:44:19 -0400 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2012-06-14 20:20:21 +0200 |
commit | e40e993cecd1663636e2f0d33b3e2a6204d64984 (patch) | |
tree | 172ed7dbfc535fd6113c8707a82e02647aaec7dc /generator | |
parent | 54cce10fa8a9942450c9e1a9d9a9d2a1b688f243 (diff) |
Find function modifications defined in the 2nd+ base class.
Fixes bug PYSIDE-54
Change-Id: Ic5c341741170cc77e8ebb59c46c746211582ddeb
Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'generator')
-rw-r--r-- | generator/shiboken/cppgenerator.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/generator/shiboken/cppgenerator.cpp b/generator/shiboken/cppgenerator.cpp index 32fcdec7e..562a1f055 100644 --- a/generator/shiboken/cppgenerator.cpp +++ b/generator/shiboken/cppgenerator.cpp @@ -666,9 +666,11 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun } bool invalidateReturn = false; + QSet<int> invalidateArgs; foreach (FunctionModification funcMod, func->modifications()) { foreach (ArgumentModification argMod, funcMod.argument_mods) { - if (argMod.resetAfterUse) { + if (argMod.resetAfterUse && !invalidateArgs.contains(argMod.index)) { + invalidateArgs.insert(argMod.index); s << INDENT << "bool invalidateArg" << argMod.index; s << " = PyTuple_GET_ITEM(" PYTHON_ARGS ", " << argMod.index - 1 << ")->ob_refcnt == 1;" << endl; } else if (argMod.index == 0 && argMod.ownerships[TypeSystem::TargetLangCode] == TypeSystem::CppOwnership) { @@ -762,16 +764,18 @@ void CppGenerator::writeVirtualMethodNative(QTextStream&s, const AbstractMetaFun Indentation indentation(INDENT); s << INDENT << "Shiboken::Object::releaseOwnership(" << PYTHON_RETURN_VAR ".object());" << endl; } + foreach (int argIndex, invalidateArgs) { + s << INDENT << "if (invalidateArg" << argIndex << ')' << endl; + Indentation indentation(INDENT); + s << INDENT << "Shiboken::Object::invalidate(PyTuple_GET_ITEM(" PYTHON_ARGS ", "; + s << (argIndex - 1) << "));" << endl; + } + foreach (FunctionModification funcMod, func->modifications()) { foreach (ArgumentModification argMod, funcMod.argument_mods) { - if (argMod.resetAfterUse) { - s << INDENT << "if (invalidateArg" << argMod.index << ')' << endl; - Indentation indentation(INDENT); - s << INDENT << "Shiboken::Object::invalidate(PyTuple_GET_ITEM(" PYTHON_ARGS ", "; - s << (argMod.index - 1) << "));" << endl; - } else if (argMod.ownerships.contains(TypeSystem::NativeCode) - && argMod.index == 0 && argMod.ownerships[TypeSystem::NativeCode] == TypeSystem::CppOwnership) { + if (argMod.ownerships.contains(TypeSystem::NativeCode) + && 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; |