Skip to content

Commit

Permalink
[cables] Be more lenient with disappearing cables
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 10, 2024
1 parent d3a5869 commit 6bf59e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,11 @@ void removeCables(const SerializedCables& cables, const score::DocumentContext&
if(cable_it != doc.cables.end())
{
auto& cable = *cable_it;
cable.source().find(ctx).removeCable(cable);
cable.sink().find(ctx).removeCable(cable);
if(auto c = cable.source().try_find(ctx))
c->removeCable(cable);

if(auto c = cable.sink().try_find(ctx))
c->removeCable(cable);
doc.cables.remove(cid.first);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@ void CreateCable::redo(const score::DocumentContext& ctx) const

model.cables.add(c);
auto ext = m_model.extend(m_cable);
auto& source = m_dat.source.find(ctx);
source.addCable(*c);
m_dat.sink.find(ctx).addCable(*c);
auto source = m_dat.source.try_find(ctx);
if(source)
source->addCable(*c);
else
return;

auto sink = m_dat.sink.try_find(ctx);
if(sink)
sink->addCable(*c);
else
return;

if(m_previousPropagate)
{
static_cast<Process::AudioOutlet&>(source).setPropagate(false);
static_cast<Process::AudioOutlet&>(*source).setPropagate(false);
}
}

Expand Down

0 comments on commit 6bf59e4

Please sign in to comment.