Viewport crashes on exit

I am using a viewport that works fine. I create a component to which I dynamically add controls. It resizes as the program runs. I use setViewedComponent to add it to the viewport and all is well. I get a nice scrolling area of controls.
But when I exit, I get Block type is invalid assert failed as it seems to try to destruct the viewed object which is owned by the MainComponent window whcih is creating all of the controls on it, so it appears to have been already destroyed.

I tried adding viewedComponentChanged(0) to remove it in both the MainComponent destructor and my Viewport class destructor, no effect.

How do I correctly disentangle the viewport so it doesn’t always crash at program exit?


From the docs:

void setViewedComponent (Component *newViewedComponent, bool deleteComponentWhenNoLongerNeeded=true)


1 Like

That is how I am adding it to the Viewport.
But changing that default true to false fixed it. Thanks!