Viewport crashes on exit


#1

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?

Thanks


#2

From the docs:

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

Rail


#3

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