From 5cf419c973ac367ab36e47abf4bde953ae533706 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 22 Jun 2018 15:43:24 +0200 Subject: shiboken: Add error handling to added functions Add some handling in case an argument type cannot be parsed. Change-Id: Ib901d023ed60f74fe82a06d8c08fd704f1350a7a Reviewed-by: Alexandru Croitor --- .../shiboken2/ApiExtractor/abstractmetabuilder.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index 0e96b4c34..09d10580c 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -715,6 +715,10 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom) const AddedFunctionList &globalUserFunctions = types->globalUserFunctions(); for (const AddedFunction &addedFunc : globalUserFunctions) { AbstractMetaFunction* metaFunc = traverseFunction(addedFunc); + if (Q_UNLIKELY(!metaFunc)) { + qFatal("Unable to traverse added global function \"%s\".", + qPrintable(addedFunc.name())); + } metaFunc->setFunctionType(AbstractMetaFunction::NormalFunction); m_globalFunctions << metaFunc; } @@ -1571,8 +1575,12 @@ void AbstractMetaBuilderPrivate::fillAddedFunctions(AbstractMetaClass *metaClass { // Add the functions added by the typesystem const AddedFunctionList &addedFunctions = metaClass->typeEntry()->addedFunctions(); - for (const AddedFunction &addedFunc : addedFunctions) - traverseFunction(addedFunc, metaClass); + for (const AddedFunction &addedFunc : addedFunctions) { + if (!traverseFunction(addedFunc, metaClass)) { + qFatal("Unable to traverse function \"%s\" added to \"%s\".", + qPrintable(addedFunc.name()), qPrintable(metaClass->name())); + } + } } void AbstractMetaBuilderPrivate::applyFunctionModifications(AbstractMetaFunction *func) @@ -1753,6 +1761,13 @@ AbstractMetaFunction* AbstractMetaBuilderPrivate::traverseFunction(const AddedFu AddedFunction::TypeInfo& typeInfo = args[i]; AbstractMetaArgument *metaArg = new AbstractMetaArgument; AbstractMetaType *type = translateType(typeInfo); + if (Q_UNLIKELY(!type)) { + qCWarning(lcShiboken, + "Unable to translate type \"%s\" of argument %d of added function \"%s\".", + qPrintable(typeInfo.name), i + 1, qPrintable(addedFunc.name())); + delete metaFunction; + return nullptr; + } type->decideUsagePattern(); metaArg->setType(type); metaArg->setArgumentIndex(i); -- cgit v1.2.3