From a6d12454983f8b1f2f8e7087de4b11ccd9126178 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 26 Jul 2018 10:41:53 +0200 Subject: shiboken: Fix non-deterministic order of some SBK type indexes Change underlying type of the type database from a QHash to a QMultiMap. Previously, there was an allEntries() accessor and a function named entries() building a QHash. Simplify this so that there is only an entries() accessor returning the QMultiMap. Refactor the various Typedatabase::find() functions to operate on an iterator range of the QMultiMap. This unearthed some bugs: 1) In the generators, the call to findType(packageName()) would return the namespace entry for "sample" instead of the intended module type entry named "sample" due to the ordering. Add a new function to search for module type entries and assert that it finds it. 2) There was a duplicate, empty primitive type entry for QModelIndexList. Task-number: PYSIDE-757 Change-Id: I1814e4ca67d306e1488398507707cfd07b3f2c78 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Alexandru Croitor --- sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 11 ++++------- sources/shiboken2/generator/shiboken2/shibokengenerator.cpp | 6 +++++- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'sources/shiboken2/generator/shiboken2') diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index f230782d1..455b77c6e 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5332,13 +5332,12 @@ bool CppGenerator::finishGeneration() } TypeDatabase* typeDb = TypeDatabase::instance(); - TypeSystemTypeEntry* moduleEntry = static_cast(typeDb->findType(packageName())); + const TypeSystemTypeEntry *moduleEntry = typeDb->findTypeSystemType(packageName()); + Q_ASSERT(moduleEntry); //Extra includes s << endl << "// Extra includes" << endl; - QVector extraIncludes; - if (moduleEntry) - extraIncludes = moduleEntry->extraIncludes(); + QVector extraIncludes = moduleEntry->extraIncludes(); for (AbstractMetaEnum *cppEnum : qAsConst(globalEnums)) extraIncludes.append(cppEnum->typeEntry()->extraIncludes()); qSort(extraIncludes.begin(), extraIncludes.end()); @@ -5352,9 +5351,7 @@ bool CppGenerator::finishGeneration() s << "// Current module's converter array." << endl; s << "SbkConverter** " << convertersVariableName() << ';' << endl; - CodeSnipList snips; - if (moduleEntry) - snips = moduleEntry->codeSnips(); + const CodeSnipList snips = moduleEntry->codeSnips(); // module inject-code native/beginning if (!snips.isEmpty()) { diff --git a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp index 16f5fafd3..a03c57e98 100644 --- a/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/shibokengenerator.cpp @@ -2483,7 +2483,11 @@ bool ShibokenGenerator::doSetup() const AbstractMetaClassList &classList = classes(); for (const AbstractMetaClass *metaClass : classList) getCode(snips, metaClass->typeEntry()); - getCode(snips, td->findType(packageName())); + + const TypeSystemTypeEntry *moduleEntry = td->findTypeSystemType(packageName()); + Q_ASSERT(moduleEntry); + getCode(snips, moduleEntry); + const FunctionGroupMap &functionGroups = getFunctionGroups(); for (FunctionGroupMapIt it = functionGroups.cbegin(), end = functionGroups.cend(); it != end; ++it) { for (AbstractMetaFunction *func : it.value()) -- cgit v1.2.3