From c66e7a4a13fbc59ca8e6b1da8e6b19eb476d2a72 Mon Sep 17 00:00:00 2001 From: jatin Date: Wed, 10 Apr 2024 19:10:58 -0700 Subject: [PATCH] Fixing lifetimes bug in PresetManager::loadPreset() --- .../Backend/chowdsp_PresetManager.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp index 5917bfa79..513abd851 100644 --- a/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp +++ b/modules/plugin/chowdsp_presets_v2/Backend/chowdsp_PresetManager.cpp @@ -135,19 +135,24 @@ void PresetManager::loadUserPresetsFromFolder (const juce::File& file) void PresetManager::loadPreset (const Preset& preset) { +#if HAS_CLAP_JUCE_EXTENSIONS + const auto presetFile = preset.getPresetFile(); + const auto presetName = preset.getName(); +#endif + saverLoader.loadPreset (preset); #if HAS_CLAP_JUCE_EXTENSIONS - if (preset.getPresetFile() == juce::File {}) + if (presetFile == juce::File {}) { clapPresetLoadedBroadcaster (CLAP_PRESET_DISCOVERY_LOCATION_PLUGIN, nullptr, - preset.getName().toRawUTF8()); + presetName.toRawUTF8()); } else { clapPresetLoadedBroadcaster (CLAP_PRESET_DISCOVERY_LOCATION_FILE, - preset.getPresetFile().getFullPathName().toRawUTF8(), + presetFile.getFullPathName().toRawUTF8(), nullptr); } #endif