diff --git a/.gitignore b/.gitignore index 45682a7b..7b8ac004 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *build*/ cmake-build*/ +.raddbg_project .vscode/ docs/ .idea/ diff --git a/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.cpp b/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.cpp index 5c5e72b8..0a250ced 100644 --- a/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.cpp +++ b/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.cpp @@ -13,13 +13,17 @@ inline ParamHolder::ParamHolder (ParamHolder* parent, std::string_view phName, b return OptionalPointer { static_cast (1024) }; }(), }, + allParamsMap { MapAllocator { arena } }, name { arena::alloc_string (*arena, phName) }, isOwning { phIsOwning } { } inline ParamHolder::ParamHolder (ChainedArenaAllocator& alloc, std::string_view phName, bool phIsOwning) - : arena { &alloc, false }, name { arena::alloc_string (*arena, phName) }, isOwning { phIsOwning } + : arena { &alloc, false }, + allParamsMap { MapAllocator { arena } }, + name { arena::alloc_string (*arena, phName) }, + isOwning { phIsOwning } { } @@ -110,6 +114,10 @@ std::enable_if_t, void> template void ParamHolder::add (ParamHolder& paramHolder, OtherParams&... others) { + // This should be the parent of the holder being added. + // Maybe we can relax this restriction if we no longer need the allParamsMap. + jassert (arena == paramHolder.arena); + allParamsMap.merge (paramHolder.allParamsMap); jassert (paramHolder.allParamsMap.empty()); // assuming no duplicate parameter IDs, all the parameters should be moved in the merge! things.insert (ThingPtr { reinterpret_cast (¶mHolder), Holder }); diff --git a/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.h b/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.h index 15edf2c2..bf696197 100644 --- a/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.h +++ b/modules/plugin/chowdsp_plugin_state/Backend/chowdsp_ParamHolder.h @@ -142,7 +142,8 @@ class ParamHolder using MapKey = std::string_view; using MapValue = ThingPtr; using MapAllocator = STLArenaAllocator, ChainedArenaAllocator>; - std::unordered_map, std::equal_to<>, MapAllocator> allParamsMap { MapAllocator { arena } }; + using AllParamsMap = std::unordered_map, std::equal_to<>, MapAllocator>; + AllParamsMap allParamsMap; std::string_view name; bool isOwning; diff --git a/tests/plugin_tests/chowdsp_plugin_state_test/ParamHolderTest.cpp b/tests/plugin_tests/chowdsp_plugin_state_test/ParamHolderTest.cpp index e9885e1a..a872c6ed 100644 --- a/tests/plugin_tests/chowdsp_plugin_state_test/ParamHolderTest.cpp +++ b/tests/plugin_tests/chowdsp_plugin_state_test/ParamHolderTest.cpp @@ -5,16 +5,17 @@ TEST_CASE ("ParamHolder Test", "[plugin][state]") { SECTION ("add()") { - chowdsp::BoolParameter::Ptr boolNested { "param1", "Param", false }; - chowdsp::ChoiceParameter::Ptr choiceNested { "param2", "Param", juce::StringArray { "One", "Two" }, 0 }; - chowdsp::ParamHolder nestedParams; - nestedParams.add (boolNested, choiceNested); - chowdsp::ParamHolder params; std::array floatParams { chowdsp::PercentParameter::Ptr { "param3", "Param", 0.5f }, chowdsp::PercentParameter::Ptr { "param4", "Param", 0.5f }, }; + + chowdsp::BoolParameter::Ptr boolNested { "param1", "Param", false }; + chowdsp::ChoiceParameter::Ptr choiceNested { "param2", "Param", juce::StringArray { "One", "Two" }, 0 }; + chowdsp::ParamHolder nestedParams { ¶ms }; + nestedParams.add (boolNested, choiceNested); + params.add (nestedParams, floatParams); auto allParamIDs = [¶ms] diff --git a/tests/plugin_tests/chowdsp_plugin_state_test/StateSerializationTest.cpp b/tests/plugin_tests/chowdsp_plugin_state_test/StateSerializationTest.cpp index 7b03c230..b2724573 100644 --- a/tests/plugin_tests/chowdsp_plugin_state_test/StateSerializationTest.cpp +++ b/tests/plugin_tests/chowdsp_plugin_state_test/StateSerializationTest.cpp @@ -116,7 +116,8 @@ using StateWithTripleOfSameType = chowdsp::PluginStateImpl;