diff options
author | David Cole <david.cole@kitware.com> | 2008-07-30 17:28:17 (GMT) |
---|---|---|
committer | David Cole <david.cole@kitware.com> | 2008-07-30 17:28:17 (GMT) |
commit | b2f041f6a899b2592477c98da0d060cc7c983a91 (patch) | |
tree | 17efd4d5bd4ec380e5d31dee13cc1c0eb67a2d98 /Source/CPack/cmCPackPackageMakerGenerator.cxx | |
parent | 0247a495c1ec8855ca70557c39af47b12c9ed7ec (diff) | |
download | CMake-b2f041f6a899b2592477c98da0d060cc7c983a91.zip CMake-b2f041f6a899b2592477c98da0d060cc7c983a91.tar.gz CMake-b2f041f6a899b2592477c98da0d060cc7c983a91.tar.bz2 |
BUG: Fix issue #7414 - do not crash when given components with circular dependencies. Thanks to Doug Gregor for the patch.
Diffstat (limited to 'Source/CPack/cmCPackPackageMakerGenerator.cxx')
-rw-r--r-- | Source/CPack/cmCPackPackageMakerGenerator.cxx | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index d35e764..049a6e4 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -829,8 +829,10 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, // on (B and A), while selecting something that depends on C--either D // or E--will automatically cause C to get selected. out << "selected=\"my.choice.selected"; - AddDependencyAttributes(component, out); - AddReverseDependencyAttributes(component, out); + std::set<const cmCPackComponent *> visited; + AddDependencyAttributes(component, visited, out); + visited.clear(); + AddReverseDependencyAttributes(component, visited, out); out << "\""; } out << ">" << std::endl; @@ -868,15 +870,23 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, //---------------------------------------------------------------------- void cmCPackPackageMakerGenerator:: -AddDependencyAttributes(const cmCPackComponent& component, cmOStringStream& out) +AddDependencyAttributes(const cmCPackComponent& component, + std::set<const cmCPackComponent *>& visited, + cmOStringStream& out) { + if (visited.find(&component) != visited.end()) + { + return; + } + visited.insert(&component); + std::vector<cmCPackComponent *>::const_iterator dependIt; for (dependIt = component.Dependencies.begin(); dependIt != component.Dependencies.end(); ++dependIt) { out << " && choices['" << (*dependIt)->Name << "Choice'].selected"; - AddDependencyAttributes(**dependIt, out); + AddDependencyAttributes(**dependIt, visited, out); } } @@ -884,15 +894,22 @@ AddDependencyAttributes(const cmCPackComponent& component, cmOStringStream& out) void cmCPackPackageMakerGenerator:: AddReverseDependencyAttributes(const cmCPackComponent& component, + std::set<const cmCPackComponent *>& visited, cmOStringStream& out) { + if (visited.find(&component) != visited.end()) + { + return; + } + visited.insert(&component); + std::vector<cmCPackComponent *>::const_iterator dependIt; for (dependIt = component.ReverseDependencies.begin(); dependIt != component.ReverseDependencies.end(); ++dependIt) { out << " || choices['" << (*dependIt)->Name << "Choice'].selected"; - AddReverseDependencyAttributes(**dependIt, out); + AddReverseDependencyAttributes(**dependIt, visited, out); } } |