diff --git a/source/backend/CarlaPlugin.hpp b/source/backend/CarlaPlugin.hpp index ea0db76bc..29850ffdc 100644 --- a/source/backend/CarlaPlugin.hpp +++ b/source/backend/CarlaPlugin.hpp @@ -262,6 +262,13 @@ public: */ const CustomData& getCustomData(const uint32_t index) const noexcept; + /*! + * Give the plugin a change to update its custom data sets. + * + * @see getCustomDataCount() and getCustomData() + */ + virtual void updateCustomData() noexcept; + /*! * Get the complete plugin chunk data into @a dataPtr. * diff --git a/source/backend/engine/CarlaEngineBridge.cpp b/source/backend/engine/CarlaEngineBridge.cpp index a312f0ddc..2fd5e606b 100644 --- a/source/backend/engine/CarlaEngineBridge.cpp +++ b/source/backend/engine/CarlaEngineBridge.cpp @@ -764,7 +764,9 @@ public: const uint32_t valueSize(fShmNonRtClientControl.readUInt()); char valueStr[valueSize+1]; carla_zeroChars(valueStr, valueSize+1); - fShmNonRtClientControl.readCustomData(valueStr, valueSize); + + if (valueSize > 0) + fShmNonRtClientControl.readCustomData(valueStr, valueSize); if (plugin != nullptr && plugin->isEnabled()) plugin->setCustomData(typeStr, keyStr, valueStr, true); diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index 324ae13a8..22f370b90 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -269,6 +269,10 @@ const CustomData& CarlaPlugin::getCustomData(const uint32_t index) const noexcep return pData->custom.getAt(index, kCustomDataFallback); } +void CarlaPlugin::updateCustomData() noexcept +{ +} + std::size_t CarlaPlugin::getChunkData(void** const dataPtr) noexcept { CARLA_SAFE_ASSERT_RETURN(dataPtr != nullptr, 0); @@ -603,6 +607,8 @@ const CarlaStateSave& CarlaPlugin::getStateSave(const bool callPrepareForSave) // --------------------------------------------------------------- // Custom Data + updateCustomData(); + for (LinkedList::Itenerator it = pData->custom.begin2(); it.valid(); it.next()) { const CustomData& cData(it.getValue(kCustomDataFallback)); diff --git a/source/backend/plugin/CarlaPluginBridge.cpp b/source/backend/plugin/CarlaPluginBridge.cpp index 6692a8ad8..2db60aeb5 100644 --- a/source/backend/plugin/CarlaPluginBridge.cpp +++ b/source/backend/plugin/CarlaPluginBridge.cpp @@ -477,7 +477,10 @@ public: // ------------------------------------------------------------------- // Information (current data) - // TODO - missing getCustomData + void updateCustomData() noexcept override + { + waitForSaved(); + } std::size_t getChunkData(void** const dataPtr) noexcept override { @@ -816,7 +819,9 @@ public: fShmNonRtClientControl.writeCustomData(key, keyLen); fShmNonRtClientControl.writeUInt(valueLen); - fShmNonRtClientControl.writeCustomData(value, valueLen); + + if (valueLen > 0) + fShmNonRtClientControl.writeCustomData(value, valueLen); fShmNonRtClientControl.commitWrite(); }