diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-10-04 08:19:51 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-10-06 08:34:00 +0200 |
commit | 1e4cbb0b1150124943248031dad4ce27503e487d (patch) | |
tree | 01b044ccdb2b253716a0680f50f00045f6e66092 | |
parent | c36a5c4978f25656c7c56d0118c2a88d55f69b77 (diff) |
shiboken6: Fix smart pointers of type <const Pointee>
Use the right function to strip the qualifications from
the type since <const Pointee> and <Pointee> are treated identically.
Fixes a regression introduced by change
a262e9bae5dbdef92d5caa0e058a1ad07fa974d3.
This is in principle tested in the smart binding test, but
occurs depending on the order the types are seen, so, add another
test.
Fixes: PYSIDE-2071
Pick-to: 6.3
Change-Id: I838b1ae1dd607095b41018c973093a380f51ab6b
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
4 files changed, 20 insertions, 1 deletions
diff --git a/sources/pyside6/tests/pysidetest/shared_pointer_test.py b/sources/pyside6/tests/pysidetest/shared_pointer_test.py index eb0b21007..6f49d69b1 100644 --- a/sources/pyside6/tests/pysidetest/shared_pointer_test.py +++ b/sources/pyside6/tests/pysidetest/shared_pointer_test.py @@ -28,6 +28,8 @@ class SharedPointerTests(unittest.TestCase): p = SharedPointerTestbench.createSharedPointerQObject() self.assertEqual(p.objectName(), "TestObject") SharedPointerTestbench.printSharedPointerQObject(p) + p = SharedPointerTestbench.createSharedPointerConstQObject() + SharedPointerTestbench.printSharedPointerConstQObject(p) def testIntSharedPointer(self): p = SharedPointerTestbench.createSharedPointerInt(42) diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp index a901570cc..57724045e 100644 --- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp +++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp @@ -29,3 +29,16 @@ void SharedPointerTestbench::printSharedPointerQObject(const QSharedPointer<QObj { qDebug() << __FUNCTION__ << p.data(); } + +QSharedPointer<const QObject> SharedPointerTestbench::createSharedPointerConstQObject() +{ + auto *o = new QObject; + o->setObjectName(u"ConstTestObject"_qs); + QSharedPointer<const QObject> result(o); + return result; +} + +void SharedPointerTestbench::printSharedPointerConstQObject(const QSharedPointer<const QObject> &p) +{ + qDebug() << __FUNCTION__ << p.data(); +} diff --git a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h index b919acd17..b23fd1b6c 100644 --- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h +++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h @@ -20,6 +20,10 @@ public: static QSharedPointer<QObject> createSharedPointerQObject(); static void printSharedPointerQObject(const QSharedPointer<QObject> &p); + + static QSharedPointer<const QObject> createSharedPointerConstQObject(); + static void printSharedPointerConstQObject(const QSharedPointer<const QObject> &p); + }; #endif // SHAREDPOINTERTESTBENCH_H diff --git a/sources/shiboken6/ApiExtractor/apiextractor.cpp b/sources/shiboken6/ApiExtractor/apiextractor.cpp index e56b8b222..01c81fffd 100644 --- a/sources/shiboken6/ApiExtractor/apiextractor.cpp +++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp @@ -499,7 +499,7 @@ void ApiExtractorPrivate::addInstantiatedSmartPointer(InstantiationCollectContex const AbstractMetaType &type) { InstantiatedSmartPointer smp; - smp.type = simplifiedType(type); + smp.type = canonicalSmartPtrInstantiation(type); smp.smartPointer = AbstractMetaClass::findClass(m_builder->smartPointers(), type.typeEntry()); Q_ASSERT(smp.smartPointer); |