diff --git a/Source/components/EffectsListComponent.cpp b/Source/components/EffectsListComponent.cpp index bfa1e5d0..6be859ee 100644 --- a/Source/components/EffectsListComponent.cpp +++ b/Source/components/EffectsListComponent.cpp @@ -5,6 +5,10 @@ EffectsListComponent::EffectsListComponent(DraggableListBox& lb, AudioEffectListBoxItemData& data, int rn, Effect& effect) : DraggableListBoxItem(lb, data, rn), effect(effect), audioProcessor(data.audioProcessor), editor(data.editor) { + if (effect.enabled == nullptr) { + DBG("Effect enabled is null"); + } + auto parameters = effect.parameters; for (int i = 0; i < parameters.size(); i++) { std::shared_ptr effectComponent = std::make_shared(audioProcessor, effect, i); diff --git a/Source/components/SwitchButton.h b/Source/components/SwitchButton.h index 3b66b837..b3743e30 100644 --- a/Source/components/SwitchButton.h +++ b/Source/components/SwitchButton.h @@ -77,8 +77,11 @@ class SwitchButton : public juce::Button, public juce::AudioProcessorParameter:: } void parameterValueChanged(int parameterIndex, float newValue) override { - juce::MessageManager::callAsync([this]() { - setToggleState(parameter->getBoolValue(), juce::NotificationType::dontSendNotification); + juce::WeakReference weakThis = this; + juce::MessageManager::callAsync([weakThis, this]() { + if (weakThis != nullptr) { + setToggleState(parameter->getBoolValue(), juce::NotificationType::dontSendNotification); + } }); } @@ -174,6 +177,8 @@ class SwitchButton : public juce::Button, public juce::AudioProcessorParameter:: bool prevToggleState = false; BooleanParameter* parameter = nullptr; + + JUCE_DECLARE_WEAK_REFERENCEABLE(SwitchButton) }; } // namespace jux