In a ValueTree I store SafePointers and ScopedPointers to Components as ReferenceCountedObject in a property. One if these owned components needs to access and modify the ValueTree where it is owned.
If I hold a reference to that ValueTree, the reference count will stop the correct destruction, because they reference each other.
Idea 1: decrement the reference count by one, when the owned component is added. As it is owned, they should be destroyed together. But sounds kind of scary. And the reference count can only be read, there is no interface to modify it (with good reason I think)
Idea 2: can I get a WeakReference to the sharedObject of a ValueTree? A WeakReference to the ValueTree itself makes no sense as I understand it.
Any ideas are welcome.