Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] On NavigationTreeObserver and listeners

Here something I discovered recently (286997).

We should be careful when using this pattern:

  NavigationTreeObserver navigationTreeObserver = new NavigationTreeObserver();
  navigationTreeObserver.addListener(new SubModuleListener());
  navigationTreeObserver.addListenerTo(someNode);

if the someNode we attach to has a longer lifecycle that the thing
that needs the listener.

Concrete example: if we invoke this in a SubModuleView and someNode is
the applicationNode, then the SubModuleListener() instance sticks
around after the submodule is closed, because it is tied to the
(longer) lifecycle of the application.

In such cases we must remove the listener from someNode when the
submodule view is closed. Fortunately this was only in one place. I've
checked the other occurrences of this pattern at they were not
problematic.

Greetings from sunny Portland (33C),
Elias.

-- 
Elias Volanakis | Technical Lead | EclipseSource Portland
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | http://eclipsesource.com


Back to the top