From d8ff3bfaae6d76fb362a6ebb403abf1a903a7ee6 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 4 Dec 2013 12:08:16 +0100 Subject: Fix artifact visitor. The current implementation is overly complex and misses sibling artifacts. Just go through the list of artifacts instead of traversing top-down. Change-Id: Ic665bfc977a1718ee298efda66d741bb701886c3 Reviewed-by: Joerg Bornemann --- src/lib/buildgraph/artifactvisitor.cpp | 11 ++--------- src/lib/buildgraph/artifactvisitor.h | 1 - src/lib/buildgraph/cycledetector.cpp | 9 +++++++++ src/lib/buildgraph/cycledetector.h | 1 + 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/lib/buildgraph/artifactvisitor.cpp b/src/lib/buildgraph/artifactvisitor.cpp index 24829c51e..c2eb6e896 100644 --- a/src/lib/buildgraph/artifactvisitor.cpp +++ b/src/lib/buildgraph/artifactvisitor.cpp @@ -42,23 +42,16 @@ ArtifactVisitor::ArtifactVisitor(int artifactType) : m_artifactType(artifactType void ArtifactVisitor::visitArtifact(Artifact *artifact) { - QBS_ASSERT(artifact, return); - if (m_allArtifacts.contains(artifact)) - return; - m_allArtifacts << artifact; + QBS_CHECK(artifact); if (m_artifactType & artifact->artifactType) doVisit(artifact); - else if (m_artifactType == Artifact::Generated) - return; - foreach (Artifact * const child, artifact->children) - visitArtifact(child); } void ArtifactVisitor::visitProduct(const ResolvedProductConstPtr &product) { if (!product->buildData) return; - foreach (Artifact * const artifact, product->buildData->targetArtifacts) + foreach (Artifact * const artifact, product->buildData->artifacts) visitArtifact(artifact); } diff --git a/src/lib/buildgraph/artifactvisitor.h b/src/lib/buildgraph/artifactvisitor.h index 6ff6a4f11..d929768b7 100644 --- a/src/lib/buildgraph/artifactvisitor.h +++ b/src/lib/buildgraph/artifactvisitor.h @@ -52,7 +52,6 @@ private: virtual void doVisit(Artifact *artifact) = 0; const int m_artifactType; - QSet m_allArtifacts; }; } // namespace Internal diff --git a/src/lib/buildgraph/cycledetector.cpp b/src/lib/buildgraph/cycledetector.cpp index bb5d0bf38..c67d80ab8 100644 --- a/src/lib/buildgraph/cycledetector.cpp +++ b/src/lib/buildgraph/cycledetector.cpp @@ -30,6 +30,7 @@ #include "artifact.h" #include "buildgraph.h" +#include "productbuilddata.h" #include #include @@ -51,6 +52,14 @@ void CycleDetector::visitProject(const ResolvedProjectConstPtr &project) ArtifactVisitor::visitProject(project); } +void CycleDetector::visitProduct(const ResolvedProductConstPtr &product) +{ + if (!product->buildData) + return; + foreach (Artifact * const artifact, product->buildData->targetArtifacts) + visitArtifact(artifact); +} + void CycleDetector::visitArtifact(Artifact *artifact) { if (Q_UNLIKELY(m_artifactsInCurrentPath.contains(artifact))) { diff --git a/src/lib/buildgraph/cycledetector.h b/src/lib/buildgraph/cycledetector.h index 61ddac0b1..dbe0d07f9 100644 --- a/src/lib/buildgraph/cycledetector.h +++ b/src/lib/buildgraph/cycledetector.h @@ -43,6 +43,7 @@ public: CycleDetector(const Logger &logger); void visitProject(const ResolvedProjectConstPtr &project); + void visitProduct(const ResolvedProductConstPtr &product); void visitArtifact(Artifact *artifact); private: -- cgit v1.2.3