Viewport & non-owned viewed components

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…

Listenerlists should use weak-pointers in general…

Huh?

No… if you look in Viewport::deleteContentComp(), you’ll see that it correctly removes the listener.

Sorry, it didn’t do that in the older version of Juce I was working with, and I must have made a mistake when searching for “removeComponentListener” when I was checking to see if this was fixed in head.