Skip to content

Commit 6c8e7dd

Browse files
authored
Better erase in the lag handler. Oops (#182)
1 parent 9f4cfc8 commit 6c8e7dd

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

include/sst/basic-blocks/dsp/LagCollection.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,17 @@ template <int N> struct LagCollection
9595

9696
void processAll()
9797
{
98-
for (auto &lag : activeSet)
98+
for (auto it = activeSet.begin(); it != activeSet.end();)
9999
{
100-
lag.process();
101-
if (!lag.lag.isActive())
102-
activeSet.removeFromActive(lag);
100+
it->process();
101+
if (!it->lag.isActive())
102+
{
103+
it = activeSet.erase(it);
104+
}
105+
else
106+
{
107+
++it;
108+
}
103109
}
104110
}
105111

tests/dsp_tests.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,9 @@ TEST_CASE("Lag Collection", "[dsp]")
13491349
lags.setTarget(3, 0.7 + lv * 0.72, &vals[3]);
13501350
}
13511351
lags.processAll();
1352-
if (i < 14)
1352+
if (i == 0)
1353+
REQUIRE(lags.activeSet.activeCount == 0);
1354+
else if (i < 14 && i >= 1)
13531355
REQUIRE(lags.activeSet.activeCount == 1);
13541356
else
13551357
REQUIRE(lags.activeSet.activeCount == 2);

0 commit comments

Comments
 (0)