From 8cef1ce5f2cb3c6f53533d5f42dd6e6db7d88fad Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 18 Dec 2020 11:25:33 +0100 Subject: shiboken6: Fix support of multiple smart pointer types The function searching for the instantiations of smart pointers was not checking for the smart pointer type entry, so, QSharedPointer was hiding std::shared_ptr. Check for the type entry as well. Rearrange the code a bit. Task-numnber: PYSIDE-454 Change-Id: Ib7a0385ce2c0f8de84b644168b0164f13f3332ad Reviewed-by: Christian Tismer (cherry picked from commit 069f7309d72b2a1f80638641ac3d6269b6aefc1d) Reviewed-by: Qt Cherry-pick Bot --- sources/shiboken6/generator/generator.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'sources') diff --git a/sources/shiboken6/generator/generator.cpp b/sources/shiboken6/generator/generator.cpp index c1d42db60..7f8167f58 100644 --- a/sources/shiboken6/generator/generator.cpp +++ b/sources/shiboken6/generator/generator.cpp @@ -282,24 +282,25 @@ void Generator::addInstantiatedContainersAndSmartPointers(const AbstractMetaType return; } - QString typeName = getSimplifiedContainerTypeName(type); if (isContainer) { + const QString typeName = getSimplifiedContainerTypeName(type); if (!m_d->instantiatedContainersNames.contains(typeName)) { m_d->instantiatedContainersNames.append(typeName); m_d->instantiatedContainers.append(type); } - } else { - // Is smart pointer. Check if the (const?) pointee is already known - auto pt = pointeeTypeEntry(type); - const bool present = - std::any_of(m_d->instantiatedSmartPointers.cbegin(), m_d->instantiatedSmartPointers.cend(), - [pt] (const AbstractMetaType &t) { - return pointeeTypeEntry(t) == pt; - }); - if (!present) - m_d->instantiatedSmartPointers.append(canonicalSmartPtrInstantiation(type)); + return; } + // Is smart pointer. Check if the (const?) pointee is already known for the given + // smart pointer type entry. + auto pt = pointeeTypeEntry(type); + const bool present = + std::any_of(m_d->instantiatedSmartPointers.cbegin(), m_d->instantiatedSmartPointers.cend(), + [typeEntry, pt] (const AbstractMetaType &t) { + return t.typeEntry() == typeEntry && pointeeTypeEntry(t) == pt; + }); + if (!present) + m_d->instantiatedSmartPointers.append(canonicalSmartPtrInstantiation(type)); } void Generator::collectInstantiatedContainersAndSmartPointers(const AbstractMetaFunctionCPtr &func) -- cgit v1.2.3