From f06b623e5883435bb78438dd46a713d91026eb21 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 3 Sep 2025 09:36:37 +0200 Subject: Reduce usage of PyTypeObject::tp_name In the Limited API, PyTypeObject is an opaque struct, for which libshiboken provides a dummy definition. PyType_GetFullyQualifiedName() (stable API since 3.13) can be used as a replacement, but it returns a PyObject. Add a convenience function PepType_GetFullyQualifiedNameStr() similar to the existing PepType_GetNameStr() to return a C-string. Leave the 3.13 code commented out for the moment since it causes a crash. This does not cover occurrences of tp_name passed as strings to Python formatting functions using the %s placeholder since that can be replaced by the new %N/%T placeholder starting from 3.13. Task-number: PYSIDE-3171 Change-Id: I4a073872cd0d138b8d8c6aafb08ccb33451812ca Reviewed-by: Shyamnath Premnadh --- sources/pyside6/libpyside/dynamicqmetaobject.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sources/pyside6/libpyside/dynamicqmetaobject.cpp') diff --git a/sources/pyside6/libpyside/dynamicqmetaobject.cpp b/sources/pyside6/libpyside/dynamicqmetaobject.cpp index 349a01499..76b02a04f 100644 --- a/sources/pyside6/libpyside/dynamicqmetaobject.cpp +++ b/sources/pyside6/libpyside/dynamicqmetaobject.cpp @@ -313,9 +313,9 @@ QMetaPropertyBuilder auto *typeObject = Property::getTypeObject(property); if (typeObject != nullptr && PyType_Check(typeObject)) { auto *pyTypeObject = reinterpret_cast(typeObject); - if (qstrncmp(pyTypeObject->tp_name, "PySide", 6) != 0 + if (qstrncmp(PepType_GetFullyQualifiedNameStr(pyTypeObject), "PySide", 6) != 0 && PySide::isQObjectDerived(pyTypeObject, false)) { - const QByteArray pyType(pyTypeObject->tp_name); + const QByteArray pyType(PepType_GetFullyQualifiedNameStr(pyTypeObject)); const auto metaType = QMetaType::fromName(pyType + '*'); if (metaType.isValid()) { return builder->addProperty(propertyName, pyType, -- cgit v1.2.3