From 007a457e1e0d18c1cfb39ca6b18b9ab246523d0b Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 11 Feb 2022 04:43:50 +0000 Subject: [PATCH] Make sure the new `updateState` calls `setState` first Signed-off-by: falkTX --- distrho/DistrhoPlugin.hpp | 4 ++-- distrho/src/DistrhoPluginLV2.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp index 138caeaa..9fdc86aa 100644 --- a/distrho/DistrhoPlugin.hpp +++ b/distrho/DistrhoPlugin.hpp @@ -994,8 +994,8 @@ public: #if DISTRHO_PLUGIN_WANT_STATE /** - Notify the host about a state value change.@n - This function will automatically trigger a state update on the UI side.@n + Set state value and notify the host about the change.@n + This function will call `setState()` and also trigger an update on the UI side as necessary.@n It must not be called during run.@n The state must be host readable. @note this function does nothing on DSSI plugin format, as DSSI only supports UI->DSP messages. diff --git a/distrho/src/DistrhoPluginLV2.cpp b/distrho/src/DistrhoPluginLV2.cpp index 2b0bb4a2..0e8df089 100644 --- a/distrho/src/DistrhoPluginLV2.cpp +++ b/distrho/src/DistrhoPluginLV2.cpp @@ -1267,10 +1267,16 @@ private: // save this key if necessary if (fPlugin.wantStateKey(key)) - updateState(key, newValue, false); + updateInternalState(key, newValue, false); } - bool updateState(const char* const key, const char* const newValue, const bool sendToUI) + bool updateState(const char* const key, const char* const newValue) + { + fPlugin.setState(key, newValue); + return updateInternalState(key, newValue, true); + } + + bool updateInternalState(const char* const key, const char* const newValue, const bool sendToUI) { // key must already exist for (StringToStringMap::iterator it=fStateMap.begin(), ite=fStateMap.end(); it != ite; ++it) @@ -1343,7 +1349,7 @@ private: #if DISTRHO_PLUGIN_WANT_STATE static bool updateStateValueCallback(void* const ptr, const char* const key, const char* const value) { - return ((PluginLv2*)ptr)->updateState(key, value, true); + return ((PluginLv2*)ptr)->updateState(key, value); } #endif