diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-03-28 10:34:45 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-01 15:36:26 +0000 |
commit | bf93d869a709393797d5c75e1341dfe5b5a60d14 (patch) | |
tree | 315972709cd03ad6041861637ce64d1f4ffd919e /sources/shiboken2/generator | |
parent | f53aed12cae42db9d142b8829b9d815b4384dced (diff) |
shiboken: Refactor AbstractMetaBuilder::classesTopologicalSorted()
Change the function parameter to be a list always, making the logic of
the inner classes clearer.
In the implementation, use a of QHash<AbstractMetaClass*, int> instead
of hashing by name, which makes it possible to disambiguate namespaces
extended in modules.
This also allows for a drastic simplification of the code trying to
determine the dependency given by parameter default values. Instead of
trying to match by name, correctly qualifying it, the matching can be
done by TypeEntry pointers.
Change-Id: Ia17bf6e109576bac029fb016e5e11309777d0735
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/generator')
-rw-r--r-- | sources/shiboken2/generator/shiboken2/cppgenerator.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp index b4337c2b1..039a2928b 100644 --- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp +++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp @@ -5430,12 +5430,13 @@ bool CppGenerator::finishGeneration() //We need move QMetaObject register before QObject Dependencies additionalDependencies; const AbstractMetaClassList &allClasses = classes(); - if (AbstractMetaClass::findClass(allClasses, qObjectClassName()) != Q_NULLPTR - && AbstractMetaClass::findClass(allClasses, qMetaObjectClassName()) != Q_NULLPTR) { - Dependency dependency; - dependency.parent = qMetaObjectClassName(); - dependency.child = qObjectClassName(); - additionalDependencies.append(dependency); + if (auto qObjectClass = AbstractMetaClass::findClass(allClasses, qObjectClassName())) { + if (auto qMetaObjectClass = AbstractMetaClass::findClass(allClasses, qMetaObjectClassName())) { + Dependency dependency; + dependency.parent = qMetaObjectClass; + dependency.child = qObjectClass; + additionalDependencies.append(dependency); + } } const AbstractMetaClassList lst = classesTopologicalSorted(additionalDependencies); |