DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit f30d19f3b96e4fbaaaa0df643d1bb38eab00e683
parent 482d8d4bb2c4cd5f7b40a446c82552f52f1dbd6d
Author: falkTX <falktx@gmail.com>
Date:   Tue, 15 Apr 2014 13:27:29 +0000

Don't save lv2 keys not registered by the plugin

Diffstat:
Mdistrho/src/DistrhoPluginInternal.hpp | 11+++++++++++
Mdistrho/src/DistrhoPluginLV2.cpp | 6+++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git 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 @@ -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; }