ValueTreePath: more ValueTree stuff


#1

Imagine this ... 

I have a ValueTree in memory.  Various objects are listening to parts of it.  

The user loads a new setup/config.  It's store on disk as a ValueTree.  I load it in by deleting the old bit of the tree and loading in the new one.

Existing ValueTree::Listeners now refer to an orphaned data in the old bit of the ValueTree.

I've got a couple of ideas.  One of which is functioning but needs more work, and before I do that I wanted to check I wasn't missing a trick. 

Solution 1.

I have this kinda working.  I have an object ValueTreePath which knows how to navigate from the root of ValueTree by looking at types and properties to find and/or create a specific location.  That monitors for changes to it's parents structure and removes and adds listeners.  It forwards ValueTree::Listener callbacks to a ValueTreePath::Listener and the objects always get the right data. Plus an additional callback for 'everything has changed'.

Solution 2. 

Be much more careful when loading data, and copy the properties over the top of the existing ValueTree nodes.

 

Any other ideas? Don't start from here for example? :)