From 207fd900cc58a54463098715620cb33d73cb7cc2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 22 Apr 2013 23:29:51 +0100 Subject: [PATCH] Fix loading LV2 states (partially closes #38) --- source/backend/engine/CarlaEngine.cpp | 2 +- source/backend/plugin/CarlaPlugin.cpp | 4 ++-- source/backend/plugin/Lv2Plugin.cpp | 10 +++++++--- source/utils/CarlaStateUtils.hpp | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/backend/engine/CarlaEngine.cpp b/source/backend/engine/CarlaEngine.cpp index 8c08d5ae6..dbd6a46cc 100644 --- a/source/backend/engine/CarlaEngine.cpp +++ b/source/backend/engine/CarlaEngine.cpp @@ -1171,7 +1171,7 @@ bool CarlaEngine::loadProject(const char* const filename) { if (isPreset || node.toElement().tagName() == "Plugin") { - const SaveState& saveState = getSaveStateDictFromXML(isPreset ? xmlNode : node); + const SaveState& saveState(getSaveStateDictFromXML(isPreset ? xmlNode : node)); CARLA_ASSERT(saveState.type != nullptr); if (saveState.type == nullptr) diff --git a/source/backend/plugin/CarlaPlugin.cpp b/source/backend/plugin/CarlaPlugin.cpp index d7e61bcea..b4e1ab3f8 100644 --- a/source/backend/plugin/CarlaPlugin.cpp +++ b/source/backend/plugin/CarlaPlugin.cpp @@ -686,8 +686,8 @@ const SaveState& CarlaPlugin::getSaveState() { const MidiProgramData& mpData(kData->midiprog.getCurrent()); - saveState.currentMidiBank = mpData.bank; - saveState.currentMidiProgram = mpData.program; + saveState.currentMidiBank = mpData.bank; + saveState.currentMidiProgram = mpData.program; } // ---------------------------- diff --git a/source/backend/plugin/Lv2Plugin.cpp b/source/backend/plugin/Lv2Plugin.cpp index 414e47b43..ba7354b8d 100644 --- a/source/backend/plugin/Lv2Plugin.cpp +++ b/source/backend/plugin/Lv2Plugin.cpp @@ -20,9 +20,8 @@ #ifdef WANT_LV2 #include "CarlaPluginGui.hpp" -#include "CarlaLv2Utils.hpp" - #include "CarlaEngineOsc.hpp" +#include "CarlaLv2Utils.hpp" #include "Lv2AtomQueue.hpp" #include @@ -3202,6 +3201,9 @@ protected: void handleProgramChanged(const int32_t index) { + CARLA_ASSERT_INT(index >= -1, index); + carla_debug("Lv2Plugin::handleProgramChanged(%i)", index); + if (index == -1) { const CarlaPlugin::ScopedDisabler m(this); @@ -3234,6 +3236,7 @@ protected: CARLA_ASSERT(key != CARLA_URI_MAP_ID_NULL); CARLA_ASSERT(value != nullptr); CARLA_ASSERT(size > 0); + carla_debug("Lv2Plugin::handleStateStore(%i, %p, " P_SIZE ", %i, %i)", key, value, size, type, flags); // basic checks if (key == CARLA_URI_MAP_ID_NULL) @@ -3307,6 +3310,7 @@ protected: const void* handleStateRetrieve(const uint32_t key, size_t* const size, uint32_t* const type, uint32_t* const flags) { CARLA_ASSERT(key != CARLA_URI_MAP_ID_NULL); + carla_debug("Lv2Plugin::handleStateRetrieve(%i, %p, %p, %p)", key, size, type, flags); // basic checks if (key == CARLA_URI_MAP_ID_NULL) @@ -3350,7 +3354,7 @@ protected: return nullptr; } - *type = key; + *type = carla_lv2_urid_map(this, stype); *flags = LV2_STATE_IS_POD; if (std::strcmp(stype, LV2_ATOM__String) == 0 || std::strcmp(stype, LV2_ATOM__Path) == 0) diff --git a/source/utils/CarlaStateUtils.hpp b/source/utils/CarlaStateUtils.hpp index c69378d3a..04bfbdf28 100644 --- a/source/utils/CarlaStateUtils.hpp +++ b/source/utils/CarlaStateUtils.hpp @@ -590,7 +590,7 @@ const QString& getXMLFromSaveState(const SaveState& saveState) customData += QString(" %1\n").arg(xmlSafeString(stateCustomData->type, true)); customData += QString(" %1\n").arg(xmlSafeString(stateCustomData->key, true)); - if (std::strcmp(stateCustomData->type, CUSTOM_DATA_CHUNK) == 0) + if (std::strcmp(stateCustomData->type, CUSTOM_DATA_CHUNK) == 0 || std::strlen(stateCustomData->value) >= 128) { customData += " \n"; customData += QString("%1\n").arg(xmlSafeString(stateCustomData->value, true));