gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit 1b01bb84a067c7b814bc8506d8eec84bd55a45de
parent fff6f5d849fdef87b69f1e5d1896f5d828d2f251
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Fri,  3 May 2024 23:55:54 +0200

fix tags may get lost if tags are modified and then a datasource is removed without ever being saved (should solve lost Favourites issue)

Diffstat:
Msource/jucePluginLib/patchdb/db.cpp | 34++++++++++++++++++++++++++--------
Msource/jucePluginLib/patchdb/db.h | 3+++
2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/source/jucePluginLib/patchdb/db.cpp b/source/jucePluginLib/patchdb/db.cpp @@ -162,6 +162,11 @@ namespace pluginLib::patchDB removePatchesFromSearches(removedPatches); { + std::unique_lock pl(m_patchesMutex); + preservePatchModifications(removedPatches); + } + + { std::unique_lock lockUi(m_uiMutex); m_dirty.dataSources = true; @@ -497,6 +502,7 @@ namespace pluginLib::patchDB return; removePatchesFromSearches(removedPatches); + preservePatchModifications(removedPatches); { std::unique_lock lockUi(m_uiMutex); @@ -959,14 +965,7 @@ namespace pluginLib::patchDB if (it == patches.end()) return false; - auto mods = _patch->modifications; - - if(mods && !mods->empty()) - { - mods->patch.reset(); - mods->updateCache(); - m_patchModifications.insert({PatchKey(*_patch), mods}); - } + preservePatchModifications(_patch); patches.erase(it); @@ -1223,6 +1222,25 @@ namespace pluginLib::patchDB return res; } + void DB::preservePatchModifications(const PatchPtr& _patch) + { + auto mods = _patch->modifications; + + if(!mods || mods->empty()) + return; + + mods->patch.reset(); + mods->updateCache(); + + m_patchModifications.insert({PatchKey(*_patch), mods}); + } + + void DB::preservePatchModifications(const std::vector<PatchPtr>& _patches) + { + for (const auto& patch : _patches) + preservePatchModifications(patch); + } + bool DB::createConsecutiveProgramNumbers(const DataSourceNodePtr& _ds) const { std::unique_lock lockPatches(m_patchesMutex); diff --git a/source/jucePluginLib/patchdb/db.h b/source/jucePluginLib/patchdb/db.h @@ -117,6 +117,9 @@ namespace pluginLib::patchDB void updateSearches(const std::vector<PatchPtr>& _patches); bool removePatchesFromSearches(const std::vector<PatchPtr>& _keys); + void preservePatchModifications(const PatchPtr& _patch); + void preservePatchModifications(const std::vector<PatchPtr>& _patches); + bool createConsecutiveProgramNumbers(const DataSourceNodePtr& _ds) const; Color getTagColorInternal(TagType _type, const Tag& _tag) const;