Ownedarray crashes when removing an object

Hi,

I’m making a synthesiser with a dynamic amount of oscillators.
So I’m giving the user the option to add or remove oscillators.

Every voice of the synthesiser is holding that amount of oscillators and it is stored in an OwnedArray.
Adding oscillators is working fine, but when I’m trying to remove an oscillator with the remove(int index, bool deleteobject) my plugin crashes when I enter true for deleteobject.
The deleteobject parameter is whether to also delete the object and not only removing it from the array.
When I enter false, there is no crash.

Who can help me?

Jelle Bakker

EDIT:
I’m sorry, I just found out the reason of the crash.
The problem was that I was adding the same oscillator instances to all the voices.
So all the voices keep the same pointer to the same oscillator.