From 8a465c1f6e156975d25938622e0299e64bf08295 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 28 Jan 2019 10:36:39 +0100 Subject: shiboken: Make constructor checks more fine-grained ShibokenGenerator::isValueTypeWithCopyConstructorOnly() returned false for QWebEngineHistoryItem since the check for AbstractMetaAttributes::HasRejectedConstructor triggered on WebEngineHistoryItem(QWebEngineHistoryItemPrivate *priv), causing the function to bail out. To prevent this, add a new AbstractMetaAttributes::HasRejectedDefaultConstructor attribute and use that in isValueTypeWithCopyConstructorOnly(). Task-number: PYSIDE-906 Change-Id: I4fee83b89f0a4c44e7e8d69e118ed7f2b03ceee1 Reviewed-by: Alexandru Croitor --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp') diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index f6724e61d..7498d3a18 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -1367,17 +1367,21 @@ static bool _compareAbstractMetaFunctions(const AbstractMetaFunction* func, cons } AbstractMetaFunctionList AbstractMetaBuilderPrivate::classFunctionList(const ScopeModelItem &scopeItem, - bool *constructorRejected) + AbstractMetaClass::Attributes *constructorAttributes) { - *constructorRejected = false; + *constructorAttributes = 0; AbstractMetaFunctionList result; const FunctionList &scopeFunctionList = scopeItem->functions(); result.reserve(scopeFunctionList.size()); for (const FunctionModelItem &function : scopeFunctionList) { - if (AbstractMetaFunction *metaFunction = traverseFunction(function)) + if (AbstractMetaFunction *metaFunction = traverseFunction(function)) { result.append(metaFunction); - else if (function->functionType() == CodeModel::Constructor) - *constructorRejected = true; + } else if (function->functionType() == CodeModel::Constructor) { + auto arguments = function->arguments(); + *constructorAttributes |= AbstractMetaAttributes::HasRejectedConstructor; + if (arguments.isEmpty() || arguments.constFirst()->defaultValue()) + *constructorAttributes |= AbstractMetaAttributes::HasRejectedDefaultConstructor; + } } return result; } @@ -1408,12 +1412,10 @@ private: void AbstractMetaBuilderPrivate::traverseFunctions(ScopeModelItem scopeItem, AbstractMetaClass *metaClass) { - bool constructorRejected = false; + AbstractMetaAttributes::Attributes constructorAttributes; const AbstractMetaFunctionList functions = - classFunctionList(scopeItem, &constructorRejected); - - if (constructorRejected) - *metaClass += AbstractMetaAttributes::HasRejectedConstructor; + classFunctionList(scopeItem, &constructorAttributes); + metaClass->setAttributes(metaClass->attributes() | constructorAttributes); for (AbstractMetaFunction *metaFunction : functions){ metaFunction->setOriginalAttributes(metaFunction->attributes()); -- cgit v1.2.3