diff options
Diffstat (limited to 'src/qml/inlinecomponentutils_p.h')
-rw-r--r-- | src/qml/inlinecomponentutils_p.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/qml/inlinecomponentutils_p.h b/src/qml/inlinecomponentutils_p.h index 50936a19f0..c7a93c870b 100644 --- a/src/qml/inlinecomponentutils_p.h +++ b/src/qml/inlinecomponentutils_p.h @@ -14,6 +14,7 @@ // We mean it. // +#include <private/qqmlmetatype_p.h> #include <private/qv4compileddata_p.h> #include <private/qv4resolvedtypereference_p.h> @@ -55,10 +56,19 @@ public: IndexType index() const { return m_data.get<IndexField>(); } }; +using NodeList = std::vector<Node>; using AdjacencyList = std::vector<std::vector<Node*>>; +inline bool containedInSameType(const QQmlType &a, const QQmlType &b) +{ + return QQmlMetaType::equalBaseUrls(a.sourceUrl(), b.sourceUrl()); +} + template<typename ObjectContainer, typename InlineComponent> -void fillAdjacencyListForInlineComponents(ObjectContainer *objectContainer, AdjacencyList &adjacencyList, std::vector<Node> &nodes, const std::vector<InlineComponent> &allICs) { +void fillAdjacencyListForInlineComponents(ObjectContainer *objectContainer, + AdjacencyList &adjacencyList, NodeList &nodes, + const std::vector<InlineComponent> &allICs) +{ using CompiledObject = typename ObjectContainer::CompiledObject; // add an edge from A to B if A and B are inline components with the same containing type // and A inherits from B (ignore indirect chains through external types for now) @@ -71,9 +81,10 @@ void fillAdjacencyListForInlineComponents(ObjectContainer *objectContainer, Adja if (targetTypeRef) { const auto targetType = targetTypeRef->type(); if (targetType.isInlineComponentType() - && targetType.containingType() == currentICTypeRef->type().containingType()) { + && containedInSameType(targetType, currentICTypeRef->type())) { auto icIt = std::find_if(allICs.cbegin(), allICs.cend(), [&](const QV4::CompiledData::InlineComponent &icSearched){ - return int(icSearched.objectIndex) == targetType.inlineComponentObjectId(); + return objectContainer->stringAt(icSearched.nameIndex) + == targetType.elementName(); }); Q_ASSERT(icIt != allICs.cend()); Node& target = nodes[i]; @@ -102,7 +113,9 @@ void fillAdjacencyListForInlineComponents(ObjectContainer *objectContainer, Adja } }; -inline void topoVisit(Node *node, AdjacencyList &adjacencyList, bool &hasCycle, std::vector<Node> &nodesSorted) { +inline void topoVisit(Node *node, AdjacencyList &adjacencyList, bool &hasCycle, + NodeList &nodesSorted) +{ if (node->hasPermanentMark()) return; if (node->hasTemporaryMark()) { @@ -121,8 +134,9 @@ inline void topoVisit(Node *node, AdjacencyList &adjacencyList, bool &hasCycle, }; // Use DFS based topological sorting (https://en.wikipedia.org/wiki/Topological_sorting) -inline std::vector<Node> topoSort(std::vector<Node> &nodes, AdjacencyList &adjacencyList, bool &hasCycle) { - std::vector<Node> nodesSorted; +inline NodeList topoSort(NodeList &nodes, AdjacencyList &adjacencyList, bool &hasCycle) +{ + NodeList nodesSorted; nodesSorted.reserve(nodes.size()); hasCycle = false; |