aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-10-04 08:19:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-10-06 18:03:24 +0000
commitac98ec361aaf3b0487d1c42c9e753ec5082dadc3 (patch)
tree4b5975c8b7c62768eb17114840691dd2bbb8b522
parent80a8022b0e9676738d028a4e7a971f9be8ba199d (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 Change-Id: I838b1ae1dd607095b41018c973093a380f51ab6b Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 1e4cbb0b1150124943248031dad4ce27503e487d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/pyside6/tests/pysidetest/shared_pointer_test.py2
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp13
-rw-r--r--sources/pyside6/tests/pysidetest/sharedpointertestbench.h4
-rw-r--r--sources/shiboken6/ApiExtractor/apiextractor.cpp2
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 e5baa551c..c0b875407 100644
--- a/sources/pyside6/tests/pysidetest/shared_pointer_test.py
+++ b/sources/pyside6/tests/pysidetest/shared_pointer_test.py
@@ -45,6 +45,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 f04059043..46875345b 100644
--- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.cpp
@@ -54,3 +54,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 1732a59e5..7abbf6d29 100644
--- a/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
+++ b/sources/pyside6/tests/pysidetest/sharedpointertestbench.h
@@ -45,6 +45,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 d45f2c543..944fe4e13 100644
--- a/sources/shiboken6/ApiExtractor/apiextractor.cpp
+++ b/sources/shiboken6/ApiExtractor/apiextractor.cpp
@@ -483,7 +483,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);