diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-05-24 09:31:56 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-05-27 20:10:21 +0200 |
commit | adad8744d65c11bc78d1976e344aac1d4abb47aa (patch) | |
tree | 09200670406964db29472706e3576726ba78c487 /sources/shiboken6/ApiExtractor/typesystemparser.cpp | |
parent | b815111f8aefd89e01b966ecc86a8c77220d7e99 (diff) |
shiboken6: Introduce an attribute for parent ownership heuristics
The parent ownership heuristics cause some unintended ownership
transfers to be generated that can cause crashes. However, completely
removing them would mean to have to explicitly specify it in each
QObject-derived class constructor.
To improve this, introduce an attribute to restrict the heuristics to
classes to which this is applicable.
For compatibility, the attribute is only honored in shiboken 6 if some
class in the type system explicitly specifies it. For shiboken 7,
it will be mandatory.
[ChangeLog][shiboken6] An type system attribute for restricting
the parent ownership heuristics to relevant classes has been
introduced.
The workaround 0e62c4db50472f8b581022c86a6be651158d0cd0
can then be reverted.
Task-number: PYSIDE-1939
Change-Id: I0fb01e9842aecbccaa686ce71b2163b20a97cbf7
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken6/ApiExtractor/typesystemparser.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/typesystemparser.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sources/shiboken6/ApiExtractor/typesystemparser.cpp b/sources/shiboken6/ApiExtractor/typesystemparser.cpp index c0b387857..8f1cf9c61 100644 --- a/sources/shiboken6/ApiExtractor/typesystemparser.cpp +++ b/sources/shiboken6/ApiExtractor/typesystemparser.cpp @@ -84,6 +84,7 @@ static inline QString isNullAttribute() { return QStringLiteral("isNull"); } static inline QString locationAttribute() { return QStringLiteral("location"); } static inline QString modifiedTypeAttribute() { return QStringLiteral("modified-type"); } static inline QString operatorBoolAttribute() { return QStringLiteral("operator-bool"); } +static inline QString parentManagementAttribute() { return QStringLiteral("parent-management"); } static inline QString pyiTypeAttribute() { return QStringLiteral("pyi-type"); } static inline QString overloadNumberAttribute() { return QStringLiteral("overload-number"); } static inline QString ownershipAttribute() { return QStringLiteral("owner"); } @@ -1818,6 +1819,11 @@ void TypeSystemParser::applyComplexTypeAttributes(const ConditionalStreamReader qCWarning(lcShiboken, "%s", qPrintable(msgInvalidAttributeValue(attribute))); } + } else if (name == parentManagementAttribute()) { + const auto attribute = attributes->takeAt(i); + if (convertBoolean(attribute.value(), parentManagementAttribute(), false)) + ctype->setTypeFlags(ctype->typeFlags() | ComplexTypeEntry::ParentManagement); + ComplexTypeEntry::setParentManagementEnabled(true); } } |