aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-05-24 08:10:48 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-24 22:03:05 +0000
commit8bc2c5c6c9a67dfbbd856be34c69c6fe6fd35494 (patch)
tree3dd3315972a923a329c5b06c2f6fd4caa92fbb83
parent216a5c10546b25d69bd1454737833928f7847324 (diff)
shiboken6: Indicate ownership transferences by constructor heuristics
Make them easier to spot in case they cause issues. Amend b0f4b96c4b3172578f9ea52fbf1556c553f7b8ce to indicate the kind of heuristics. Task-number: PYSIDE-1939 Change-Id: I01909885ecf2367791de3ec71d471b3dec4d6bef Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> (cherry picked from commit b40aa266275898d983592d89158e77f9d38dd40b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index 26a5340b5..a998aa7a0 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -6782,6 +6782,7 @@ bool CppGenerator::writeParentChildManagement(TextStream &s, const AbstractMetaF
{
const int numArgs = func->arguments().size();
bool ctorHeuristicEnabled = func->isConstructor() && useCtorHeuristic() && useHeuristicPolicy;
+ bool heuristicTriggered = false;
ArgumentOwner argOwner = getArgumentOwner(func, argIndex);
ArgumentOwner::Action action = argOwner.action;
@@ -6793,6 +6794,7 @@ bool CppGenerator::writeParentChildManagement(TextStream &s, const AbstractMetaF
action = ArgumentOwner::Add;
parentIndex = argIndex;
childIndex = -1;
+ heuristicTriggered = true;
}
}
@@ -6825,7 +6827,11 @@ bool CppGenerator::writeParentChildManagement(TextStream &s, const AbstractMetaF
? pythonArgsAt(childIndex - 1) : PYTHON_ARG;
}
- s << "Shiboken::Object::setParent(" << parentVariable << ", " << childVariable << ");\n";
+ s << "// Ownership transferences";
+ if (heuristicTriggered)
+ s << " (constructor heuristics)";
+ s << ".\nShiboken::Object::setParent(" << parentVariable << ", "
+ << childVariable << ");\n";
return true;
}
@@ -6863,7 +6869,7 @@ void CppGenerator::writeReturnValueHeuristics(TextStream &s, const AbstractMetaF
ArgumentOwner argOwner = getArgumentOwner(func, ArgumentOwner::ReturnIndex);
if (argOwner.action == ArgumentOwner::Invalid || argOwner.index != ArgumentOwner::ThisIndex) {
if (type.isPointerToWrapperType()) {
- s << "// Ownership transferences (heuristics).\n"
+ s << "// Ownership transferences (return value heuristics).\n"
<< "Shiboken::Object::setParent(self, " << PYTHON_RETURN_VAR << ");\n";
}
}