Have been looking at ValueTreeObjectList and am trying to understand how to use them correctly in the following context…
I have a list of Chord objects stored in a ValueTreeObjectList called ChordList and follow the pattern in the Tracktion examples ( createObject etc )
When we change a preset, the list is cleared and rebuilt from the new preset value tree. This can happen on a separate preset load thread.
The interface components that represent the Chord objects stored in ChordList have individual pointers to the Chords as RefCountedObjectPtr. We do this as the ChordList needs to exist outside of the GUI life cycle.
When I create an interface component from a Chord stored in ChordList, I store the it as: RefCountedObjectPtr chordInInterface.
If we clear the list, the ownership of the Chord will now with chordInInterface as clearing the list will decrement the ref count by 1, but it won’t be zero because there we had a ref count of 2: chordInInterface and the one in ChordList.
While the preset is loading, even though ChordList is cleared, the Chord components on the screen will not have dangling pointers to deleted Chords due to chordInInterface and the ref count of 1.
Then after the preset load has finished, we message and the interface that it needs to rebuild itself from the new ChordList.
Does this seem like the correct way to use the ValueTreeObjectList or am I missing something? There are no specific examples in Tracktion that do this as far as I can see, maybe because of the fact Tracktion is standalone and not a plugin.