New AudioProcessorValueTreeState::SliderAttachment - error


OK, I have another problem,
I made about 10 plugins, and almost always I used value tree state, and there was no problem.
But suddenly with my new plugin I have problem with that code:

coefA0Attache = new AudioProcessorValueTreeState::SliderAttachment (processor.tree, “coefA0”, _A0);

xCode doesn’t show any problem, and plugin works great. The problem is in Logic Pro X. When I open plugin everything works, but when I close it (click cross “x” on the top left corner of window or cmd+w) even without any changes, the whole Logic crushes, just disappears, and give me allert: Logic Pro X quit unexpectedly while using the wojtekEQL plug-in.

I am sure that problem is caused by code I mentioned above, because without that there is no problem. Could anybody give me some advice what can be wrong? I can’t check in other DAW, because I don’t have anyone except Logic.

And as I told, with other of my plugins there is no such problem, and I see no difference in using value tree state. I always use it in the same manner, and there is no problems, just now with my latest plugin. Don’t know what to do, please help.

For any help thanks in advance. Best regards.

Closing the Plug-In makes the DAW crash

Forgot to mention, the


is a ScopedPointer of type AudioProcessorValueTreeState::SliderAttachment


I’ve just checked, it’s not only Logic Pro problem,
In Juce pluginHost it’s the same behaviour,
but now I have some feedback from xCode:

inline ElementType* get() const noexcept { return data; }

and for that line there is message:
Juce Message Thread (1): EXC_BAD_ACCESS (code=1, address=0x30)



Hello, thanks for reply, and feel better I am not alone with my error :slight_smile:
But isn’t there any advice how to deal with that? In your reply I can’t figure it out. But English is not my first language, so maybe I just don’t understand something. On the end you write something about removing listeners from Array. But actually I haven’t any listeners in my project, and I am not sure what you mean “array”, even if I have sometimes listeners I never put it in any Array. So maybe I should. But how to do that? And finally would it help for my issue with closing plugins?


OK, I’ve just checked, and I still had inherited from Slider::Listener, and had empty sliderValueChanged overrode, so I removed all of that, but the problem still occurs. I mean I still can’t close plugin window, because I get error:
inline ElementType* get() const noexcept { return data; }

So it seems the issue has nothing to do with listeners.


OK, I’ve found the solution. You just need to remove ScopedPointers and replace it with regular pointer. I mean:
AudioProcessorValueTreeState::SliderAttachment* coefA0Attache;
and remember to delete dynamic allocated memory in the descructor. Voilà !!! :slight_smile:


You need to make sure that your sliderAttachment will be deleted before your slider. If it‘s the other way round, your sliderAttachment may try to Access a slider just in the moment when the slider was deleted but the attachment isn‘t. This will obviously result in a segfault.


Well this way you can solve it too, it will have the effect I described above. But dealing with raw pointers and manually calling delete is something you might want to avoid at all cost. Better stick to the ScopedPointer and manually assign a nullprt to it in the destructor. This will have the same effect.


Hello, thanks for reply, assigning nullptr to ScopedPointer also work, so I use that method. Thanks.