Prevent setting toggle state after object deletion

pull/249/head
James H Ball 2024-08-21 11:11:48 +01:00 zatwierdzone przez James H Ball
rodzic bed8997a2a
commit f160c67f9f
2 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -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> effectComponent = std::make_shared<EffectComponent>(audioProcessor, effect, i);

Wyświetl plik

@ -77,8 +77,11 @@ public:
}
void parameterValueChanged(int parameterIndex, float newValue) override {
juce::MessageManager::callAsync([this]() {
setToggleState(parameter->getBoolValue(), juce::NotificationType::dontSendNotification);
juce::WeakReference<SwitchButton> weakThis = this;
juce::MessageManager::callAsync([weakThis, this]() {
if (weakThis != nullptr) {
setToggleState(parameter->getBoolValue(), juce::NotificationType::dontSendNotification);
}
});
}
@ -174,6 +177,8 @@ private:
bool prevToggleState = false;
BooleanParameter* parameter = nullptr;
JUCE_DECLARE_WEAK_REFERENCEABLE(SwitchButton)
};
} // namespace jux