diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp index ad10e566..cdc8b8a4 100644 --- a/distrho/src/DistrhoPluginInternal.hpp +++ b/distrho/src/DistrhoPluginInternal.hpp @@ -258,6 +258,17 @@ public: #endif #if DISTRHO_PLUGIN_WANT_STATE + bool wantsStateKey(const char* const key) const noexcept + { + for (uint32_t i=0; i < fData->stateCount; ++i) + { + if (fData->stateKeys[i] == key) + return true; + } + + return false; + } + uint32_t getStateCount() const noexcept { return fData != nullptr ? fData->stateCount : 0; diff --git a/distrho/src/DistrhoPluginLV2.cpp b/distrho/src/DistrhoPluginLV2.cpp index 64d87897..6aa11e79 100644 --- a/distrho/src/DistrhoPluginLV2.cpp +++ b/distrho/src/DistrhoPluginLV2.cpp @@ -644,6 +644,10 @@ private: { fPlugin.setState(key, newValue); + // check if we want to save this key + if (! fPlugin.wantsStateKey(key)) + return; + // check if key already exists for (auto it = fStateMap.begin(), end = fStateMap.end(); it != end; ++it) { @@ -656,7 +660,7 @@ private: } } - // add a new one then + // nope, add a new one then d_string d_key(key); fStateMap[d_key] = newValue; }