Robust remove() API
I experienced a strange behavior that took me a lot to understand due to a not robust API for removing wolf nodes.
There is an automatic removal of the parent node if it ran out of children. For instance, when the last feature of a capture is removed, the Capture::remove() calls Frame::remove(). This is quite invisible by the user that just typed capture->remove(). And it ends up in this very strange behavior in some specific cases of the ProcessorTrackerFeature workflow.
Protections
- For now, I added an assertion in all wolf nodes
link()function checking thatis_removing_ == false: you can't link a node that has been removed (even if you have its pointer so then it is alive..). - The functions
getChildrenList()are returning via non-const reference. Then, the list of children of the nodes can be modified from the outside. I switched them to const reference return. - We have to control this automatic empty parent removal. One solution could be adding a
boolparameter in the function:remove(bool viral_remove_empty_parent=false)that performs this automatic removal of parents (viraly) only when it is true.
Edited by Joan Vallvé Navarro