Skip to content

Commit

Permalink
[cables] Do not save cables twice
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 19, 2024
1 parent b660418 commit f1c441e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ getCablesInChildObjects(QObjectList objs, const score::DocumentContext& ctx)
{
for(auto& cbl : p->cables())
{
cables.push_back(&cbl.find(ctx));
auto* c = &cbl.find(ctx);
if(!ossia::contains(cables, c))
cables.push_back(c);
}
}

Expand Down Expand Up @@ -83,7 +85,12 @@ SerializedCables saveCables(QObjectList objs, const score::DocumentContext& ctx)
for(auto& cbl : p->cables())
{
Process::Cable& c = cbl.find(ctx);
cables.push_back({c.id(), c.toCableData()});
auto it
= ossia::find_if(cables, [&c](auto& pair) { return pair.first == c.id(); });
if(it == cables.end())
{
cables.push_back({c.id(), c.toCableData()});
}
}
}

Expand Down

0 comments on commit f1c441e

Please sign in to comment.