diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-21 13:10:17 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-09-21 19:19:09 +0200 |
commit | 936cc4c72e2393ed59e05dca1100150d88b52645 (patch) | |
tree | 58d9d312689529a698c171aa874e98338e2e2356 /sources/shiboken2/ApiExtractor | |
parent | 26a50da482c12bbbfcc8cea46aecd9f0c8305ca6 (diff) |
Shiboken2: Take member fields into account when sorting classes
The type converters for class-type member fields need to be initialized
before the respective classes; thus a dependency needs to be added
Generator::classesTopologicalSorted().
Factor out common code and loop over the member fields,
adding the dependencies to the graph.
Task-number: PYSIDE-1224
Change-Id: Iec306aa7559453d41f7f62fefd5825db66aa4815
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/ApiExtractor')
-rw-r--r-- | sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp index ae3237e8b..278c0b9c4 100644 --- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp +++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp @@ -3010,6 +3010,19 @@ static ClassIndexHash::ConstIterator findByTypeEntry(const ClassIndexHash &map, return it; } +// Add a dependency of the class associated with typeEntry on clazz +static void addClassDependency(const TypeEntry *typeEntry, + const AbstractMetaClass *clazz, + int classIndex, const ClassIndexHash &map, + Graph *graph) +{ + if (typeEntry->isComplex() && typeEntry != clazz->typeEntry()) { + const auto it = findByTypeEntry(map, typeEntry); + if (it != map.cend() && it.key()->enclosingClass() != clazz) + graph->addEdge(it.value(), classIndex); + } +} + AbstractMetaClassList AbstractMetaBuilderPrivate::classesTopologicalSorted(const AbstractMetaClassList &classList, const Dependencies &additionalDependencies) const { @@ -3062,15 +3075,17 @@ AbstractMetaClassList AbstractMetaBuilderPrivate::classesTopologicalSorted(const // ("QString s = QString()"), add a dependency. if (!arg->originalDefaultValueExpression().isEmpty() && arg->type()->isValue()) { - auto typeEntry = arg->type()->typeEntry(); - if (typeEntry->isComplex() && typeEntry != clazz->typeEntry()) { - auto ait = findByTypeEntry(map, typeEntry); - if (ait != map.cend() && ait.key()->enclosingClass() != clazz) - graph.addEdge(ait.value(), classIndex); - } + addClassDependency(arg->type()->typeEntry(), clazz, classIndex, + map, &graph); } } } + // Member fields need to be initialized + const AbstractMetaFieldList &fields = clazz->fields(); + for (AbstractMetaField *field : fields) { + addClassDependency(field->type()->typeEntry(), clazz, classIndex, + map, &graph); + } } AbstractMetaClassList result; |