removeChildComponent missing in Viewport::setViewedComponent

Hi,

I believe that contentHolder.removeChildComponent(contentComp) should probably be called in Viewport::deleteContentComp() to account for the case where Viewport::setViewedComponent is called with deleteComponentWhenNoLongerNeeded flag set to false. Unless that is happening an unmanaged component will stay in the viewport and might (depending on the call order) obscure the newly set viewed component.

Hi there,

Hmm... I'm not so sure. Viewport::setViewedComponent() calls Viewport::deleteContentComp(). If the deleteComponentWhenNoLongerNeeded flag is set to false, then the latter will set the contentComp to nullptr, which will call the component's destructor. So I don't see a way how it could stay in the viewport?

And then, even if we would call contentHolder.removeChildComponent() afterwards, if you look inside the implementation of Component::removeChildComponent, you'll see that it doesn't do anything anyway if the child in question is a nullptr.

...unless I am overlooking something and/or do not understand your specific use case ;-)