aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-16 15:14:34 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-22 16:36:33 +0100
commite4bcfacccaf1c2e5fa0e5a3fdb06266633512e53 (patch)
treec079b3e6b3822d91181572d3930ac3ddf4be9679
parent5512a93e988992b1f22b3b3561b361a2903668ac (diff)
shiboken6: Add explanatory comment about issues of field getters in lists
Task-number: PYSIDE-2252 Change-Id: I7fc3f69025913ffcf03d6d08ce4fdc958cf36267 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
-rw-r--r--sources/shiboken6/generator/shiboken/cppgenerator.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
index dfb20544e..22b302942 100644
--- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp
+++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp
@@ -5192,7 +5192,14 @@ void CppGenerator::writeGetterFunction(TextStream &s,
<< "Py_IncRef(pyOut);" << "\n"
<< "return pyOut;" << "\n"
<< outdent << "}\n";
- // Create and register new wrapper
+ // Create and register new wrapper. We force a pointer conversion also
+ // for wrapped value types so that they refer to the struct member,
+ // avoiding any trouble copying them. Add a parent relationship to
+ // properly notify if the struct is deleted (see protected_test.py,
+ // testProtectedValueTypeProperty()). Note that this has currently
+ // unsolved issues when using temporary Python lists of structs
+ // which can cause elements to be reported deleted in expressions like
+ // "foo.list_of_structs[2].field".
s << "pyOut = "
<< "Shiboken::Object::newObject(" << cpythonTypeNameExt(fieldType)
<< ", " << cppField << ", false, true);\n"