BUG: Fix issue #7414 - do not crash when given components with circular dependencies. Thanks to Doug Gregor for the patch.
This commit is contained in:
parent
0247a495c1
commit
b2f041f6a8
|
@ -829,8 +829,10 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
|
||||||
// on (B and A), while selecting something that depends on C--either D
|
// on (B and A), while selecting something that depends on C--either D
|
||||||
// or E--will automatically cause C to get selected.
|
// or E--will automatically cause C to get selected.
|
||||||
out << "selected=\"my.choice.selected";
|
out << "selected=\"my.choice.selected";
|
||||||
AddDependencyAttributes(component, out);
|
std::set<const cmCPackComponent *> visited;
|
||||||
AddReverseDependencyAttributes(component, out);
|
AddDependencyAttributes(component, visited, out);
|
||||||
|
visited.clear();
|
||||||
|
AddReverseDependencyAttributes(component, visited, out);
|
||||||
out << "\"";
|
out << "\"";
|
||||||
}
|
}
|
||||||
out << ">" << std::endl;
|
out << ">" << std::endl;
|
||||||
|
@ -868,15 +870,23 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmCPackPackageMakerGenerator::
|
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;
|
std::vector<cmCPackComponent *>::const_iterator dependIt;
|
||||||
for (dependIt = component.Dependencies.begin();
|
for (dependIt = component.Dependencies.begin();
|
||||||
dependIt != component.Dependencies.end();
|
dependIt != component.Dependencies.end();
|
||||||
++dependIt)
|
++dependIt)
|
||||||
{
|
{
|
||||||
out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
|
out << " && choices['" << (*dependIt)->Name << "Choice'].selected";
|
||||||
AddDependencyAttributes(**dependIt, out);
|
AddDependencyAttributes(**dependIt, visited, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -884,15 +894,22 @@ AddDependencyAttributes(const cmCPackComponent& component, cmOStringStream& out)
|
||||||
void
|
void
|
||||||
cmCPackPackageMakerGenerator::
|
cmCPackPackageMakerGenerator::
|
||||||
AddReverseDependencyAttributes(const cmCPackComponent& component,
|
AddReverseDependencyAttributes(const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent *>& visited,
|
||||||
cmOStringStream& out)
|
cmOStringStream& out)
|
||||||
{
|
{
|
||||||
|
if (visited.find(&component) != visited.end())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visited.insert(&component);
|
||||||
|
|
||||||
std::vector<cmCPackComponent *>::const_iterator dependIt;
|
std::vector<cmCPackComponent *>::const_iterator dependIt;
|
||||||
for (dependIt = component.ReverseDependencies.begin();
|
for (dependIt = component.ReverseDependencies.begin();
|
||||||
dependIt != component.ReverseDependencies.end();
|
dependIt != component.ReverseDependencies.end();
|
||||||
++dependIt)
|
++dependIt)
|
||||||
{
|
{
|
||||||
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
|
out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
|
||||||
AddReverseDependencyAttributes(**dependIt, out);
|
AddReverseDependencyAttributes(**dependIt, visited, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,12 +88,15 @@ protected:
|
||||||
// Subroutine of WriteDistributionFile that writes out the
|
// Subroutine of WriteDistributionFile that writes out the
|
||||||
// dependency attributes for inter-component dependencies.
|
// dependency attributes for inter-component dependencies.
|
||||||
void AddDependencyAttributes(const cmCPackComponent& component,
|
void AddDependencyAttributes(const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent *>& visited,
|
||||||
cmOStringStream& out);
|
cmOStringStream& out);
|
||||||
|
|
||||||
// Subroutine of WriteDistributionFile that writes out the
|
// Subroutine of WriteDistributionFile that writes out the
|
||||||
// reverse dependency attributes for inter-component dependencies.
|
// reverse dependency attributes for inter-component dependencies.
|
||||||
void AddReverseDependencyAttributes(const cmCPackComponent& component,
|
void
|
||||||
cmOStringStream& out);
|
AddReverseDependencyAttributes(const cmCPackComponent& component,
|
||||||
|
std::set<const cmCPackComponent *>& visited,
|
||||||
|
cmOStringStream& out);
|
||||||
|
|
||||||
// Generates XML that encodes the hierarchy of component groups and
|
// Generates XML that encodes the hierarchy of component groups and
|
||||||
// their components in a form that can be used by distribution
|
// their components in a form that can be used by distribution
|
||||||
|
|
Loading…
Reference in New Issue