Skip to content

Commit

Permalink
No Loops
Browse files Browse the repository at this point in the history
No, I don't want no loops. A loop is a color whose defined
recursively. But if that recursion comes back round to myself
I used to crash badly.

Closes surge-synthesizer#1649
  • Loading branch information
baconpaul committed Mar 21, 2020
1 parent 713933c commit 4e75822
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/common/gui/SkinSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,20 @@ bool Skin::hasColor(std::string id)
queried_colors.insert(id);
return colors.find(id) != colors.end();
}
VSTGUI::CColor Skin::getColor(std::string id, const VSTGUI::CColor& def)
VSTGUI::CColor Skin::getColor(std::string id, const VSTGUI::CColor& def, std::unordered_set<std::string> noLoops)
{
if( noLoops.find( id ) != noLoops.end() )
{
std::ostringstream oss;
oss << "Resoving color '" << id << "' resulted in a loop. Please check your XML. Colors which were visited during traversal are: ";
for( auto l : noLoops )
oss << "'" << l << "' ";
// FIXME ERROR
Surge::UserInteractions::promptError( oss.str(), "Skin Configuration Error" );
return def;
}
queried_colors.insert(id);
noLoops.insert(id);
if (colors.find(id) != colors.end())
{
auto c = colors[id];
Expand All @@ -414,7 +425,7 @@ VSTGUI::CColor Skin::getColor(std::string id, const VSTGUI::CColor& def)
case ColorStore::COLOR:
return c.color;
case ColorStore::ALIAS:
return getColor( c.alias, def );
return getColor( c.alias, def, noLoops );
}
}
return def;
Expand Down
2 changes: 1 addition & 1 deletion src/common/gui/SkinSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Skin
};

bool hasColor( std::string id );
VSTGUI::CColor getColor( std::string id, const VSTGUI::CColor &def );
VSTGUI::CColor getColor( std::string id, const VSTGUI::CColor &def, std::unordered_set<std::string> noLoops = std::unordered_set<std::string>() );
std::unordered_set<std::string> getQueriedColors() { return queried_colors; }

private:
Expand Down

0 comments on commit 4e75822

Please sign in to comment.