On Fri, 2 Jul 2021 22:58:02 GMT, Marius Hanl <mh...@openjdk.org> wrote:

>> Okay, went through listener registrations in all behaviors - and they are 
>> indeed inconsistent: 
>> 
>> - some listen to control properties like focused (f.i. Button, Combo): 
>> adding strong, often inline listeners
>> - some listen to control path properties like selection/Model/Indices (f.i. 
>> ListView, TreeView): adding weak (inline or field) wrappers 
>> - cleanup for all guarantees to make those listeners removable (without 
>> touching their type) and actually remove them in dispose
>> 
>> So I tend to follow that approach here as well, opinions?
>
> I'm also interested in the opinion from others. I think we are a bit more 
> safer with weak listener and there are used often as well. 
> But as you correctly mentioned a lot of times (still) a listener is created 
> inline. But I think on most occurences where it is not it is wrapped in an 
> weak one.

The main idea here is that we must remove the added listeners. 
A Strong listener can cause leak and a WeakListener will not cause leak, but if 
not removed then a WeakListener would be executed before it gets GCed.
As long as we are removing them properly on disposal, they both look similar to 
me, but yes we can be consistent in choosing appropriate listener.
IMO, we can keep it out of scope of this PR, It can be taken as a follow up 
issue and make a consistent change in bulk.

-------------

PR: https://git.openjdk.java.net/jfx/pull/534

Reply via email to