Skip to content

Commit

Permalink
Fix a crash when mis-subscribing to macros
Browse files Browse the repository at this point in the history
While in there, let you bulk-subscribe too

Closes surge-synthesizer#5473
  • Loading branch information
baconpaul committed Nov 25, 2021
1 parent a5a41fd commit e645019
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/common/dsp/modulators/FormulaModulationHelper.cpp
Original file line number Diff line number Diff line change
@@ -283,16 +283,26 @@ end

lua_pushstring(s.L, "macros");
lua_gettable(s.L, -2);
for (int i = 0; i < n_customcontrollers; ++i)
if (lua_isboolean(s.L, -1))
{
lua_pushnumber(s.L, i + 1);
lua_gettable(s.L, -2);
bool res = false;
if (lua_isboolean(s.L, -1))
res = lua_toboolean(s.L, -1);
lua_pop(s.L, 1);
s.subAnyMacro = s.subAnyMacro | res;
s.subMacros[i] = res;
auto b = lua_toboolean(s.L, -1);
s.subAnyMacro = b;
for (int i = 0; i < n_customcontrollers; ++i)
s.subMacros[i] = b;
}
else if (lua_istable(s.L, -1))
{
for (int i = 0; i < n_customcontrollers; ++i)
{
lua_pushnumber(s.L, i + 1);
lua_gettable(s.L, -2);
bool res = false;
if (lua_isboolean(s.L, -1))
res = lua_toboolean(s.L, -1);
lua_pop(s.L, 1);
s.subAnyMacro = s.subAnyMacro | res;
s.subMacros[i] = res;
}
}
lua_pop(s.L, 1);

0 comments on commit e645019

Please sign in to comment.