diff --git a/src/processors/BaseProcessor.cpp b/src/processors/BaseProcessor.cpp index ebf4bdac..726d05a4 100644 --- a/src/processors/BaseProcessor.cpp +++ b/src/processors/BaseProcessor.cpp @@ -1,6 +1,7 @@ #include "BaseProcessor.h" #include "gui/pedalboard/editors/ProcessorEditor.h" #include "netlist_helpers/NetlistViewer.h" +#include "state/ParamForwardManager.h" BaseProcessor::BaseProcessor (const String& name, ParamLayout params, @@ -139,7 +140,7 @@ std::unique_ptr BaseProcessor::toXML() xml->setAttribute ("x_pos", (double) editorPosition.x); xml->setAttribute ("y_pos", (double) editorPosition.y); - xml->setAttribute ("forwarding_params_slot_index", forwardingParamsSlotIndex); + xml->setAttribute (chowdsp::toString (ParamForwardManager::processorSlotIndexTag), forwardingParamsSlotIndex); if (netlistCircuitQuantities != nullptr) { @@ -164,7 +165,7 @@ void BaseProcessor::fromXML (XmlElement* xml, const chowdsp::Version&, bool load vts.state = ValueTree::fromXml (*xml); // don't use `replaceState()` otherwise UndoManager will clear - forwardingParamsSlotIndex = xml->getIntAttribute ("forwarding_params_slot_index", -1); + forwardingParamsSlotIndex = xml->getIntAttribute (chowdsp::toString (ParamForwardManager::processorSlotIndexTag), -1); if (loadPosition) loadPositionInfoFromXML (xml); diff --git a/src/processors/chain/ProcessorChainStateHelper.cpp b/src/processors/chain/ProcessorChainStateHelper.cpp index 38c3de4e..9a1bb603 100644 --- a/src/processors/chain/ProcessorChainStateHelper.cpp +++ b/src/processors/chain/ProcessorChainStateHelper.cpp @@ -74,14 +74,17 @@ void ProcessorChainStateHelper::loadProcChain (const XmlElement* xml, }); } -std::unique_ptr ProcessorChainStateHelper::saveProcChain() +std::unique_ptr ProcessorChainStateHelper::saveProcChain (bool savingPreset) { auto xml = std::make_unique (procChainStateTag); auto saveProcessor = [&] (BaseProcessor* proc) { auto procXml = std::make_unique (ChainStateHelperFuncs::getProcessorTagName (proc)); - procXml->addChildElement (proc->toXML().release()); + auto procParamsXml = proc->toXML(); + if (savingPreset) + procParamsXml->removeAttribute (chowdsp::toString (ParamForwardManager::processorSlotIndexTag)); + procXml->addChildElement (procParamsXml.release()); for (int portIdx = 0; portIdx < proc->getNumOutputs(); ++portIdx) { diff --git a/src/processors/chain/ProcessorChainStateHelper.h b/src/processors/chain/ProcessorChainStateHelper.h index 6865f745..ae1ba5f2 100644 --- a/src/processors/chain/ProcessorChainStateHelper.h +++ b/src/processors/chain/ProcessorChainStateHelper.h @@ -7,7 +7,7 @@ class ProcessorChainStateHelper public: ProcessorChainStateHelper (ProcessorChain& thisChain, chowdsp::DeferredAction& deferredAction); - std::unique_ptr saveProcChain(); + std::unique_ptr saveProcChain (bool savingPreset = false); void loadProcChain (const XmlElement* xml, const chowdsp::Version& stateVersion, bool loadingPreset = false, diff --git a/src/state/ParamForwardManager.h b/src/state/ParamForwardManager.h index 1346d13c..43badd08 100644 --- a/src/state/ParamForwardManager.h +++ b/src/state/ParamForwardManager.h @@ -10,6 +10,7 @@ class ParamForwardManager : public chowdsp::ForwardingParametersManager& presets, const std::unique_ptr PresetManager::savePresetState() { - auto xml = procChain->getStateHelper().saveProcChain(); + auto xml = procChain->getStateHelper().saveProcChain (true); StateManager::setCurrentPluginVersionInXML (xml.get()); return xml; }