When you add the viewed component to a Viewport via the setViewedComponent() method, the Viewport adds itself as a ComponentListener to the class. But even if it doesn’t own the class, it never removes itself as a component listener from the viewed component when its destructor is called, and because Viewport inherits ComponentListener privately, it can’t be done from outside the Viewport either. This means that the viewed component will have a dangling pointer to the Viewport after the Viewport is destroyed…
This problem is in head and earlier versions of Juce…