Would it be possible to have a kind of ValueTreeWeakReference? I.e., an object which refers to a shared ValueTree content object only if it still exists, without keeping it alive; it could plop out a ValueTree for its target, which would be invalid if it’s already been destroyed elsewhere.
I won’t go into detail about the cases I’d be wanting it for just yet - first just thought I’d gauge the level of offence caused by the suggestion.
Hmm… Not crazy about the idea… It’d mean adding another data member to every ValueTree to support the weak reference, so would need to have a pretty good reason for adding it.
well, the main issue I have isn’t actually knowing whether it’s still in use, but allowing it to actually be destroyed naturally whilst something else is interested in knowing where the data is [without actually holding a ValueTree of it, as that would keep it alive].
Not to worry, I can achieve the same end by having a ‘search’ to re-locate the node, but I would have preferred to not have to - though of course not at the expense of the ValueTree’s slender perfection :)].
was just thinking some more about this, and how i might be able to do something with the reference count - but there’s no access to the reference count anyway, is there? [as the count belongs to the secret shared object]
Value provides access to its ValueSource, but then ValueSource is also a visible class [whereas the ValueTree is a maximum security vault]. It’d be nice to be able to have access to the refcount like you can with refcounted objects in general, but it’s obviously pretty dangerous for the wrapper to have a direct interface to it.