Removing listeners in JFace [message #294674] |
Wed, 16 November 2005 07:43 |
Eclipse User |
|
|
|
Originally posted by: bernhard.xxxxxxx.xxx
When I looked at the code in some of the JFace components I came across
listeners being added to components but never removed. Like for example
in the ComboBoxCellEditor there are listeners added to the CCombo but are
never removed from the CCombo would it not cause some sort of memory leak?
code snippet of the createControl method:
comboBox.addKeyListener(new KeyAdapter() {
// hook key pressed - see PR 14201
public void keyPressed(KeyEvent e) {
keyReleaseOccured(e);
}
});
I am just wondering if this is a problem or do the listeners get disposed
once th e CCombo is disposed?
|
|
|
|
Re: Removing listeners in JFace [message #294684 is a reply to message #294676] |
Wed, 16 November 2005 12:04 |
Eclipse User |
|
|
|
Originally posted by: Bernhard.xxxx.xxx
Markus Wolf wrote:
>> When I looked at the code in some of the JFace components I came across
>> listeners being added to components but never removed. Like for example
>> in the ComboBoxCellEditor there are listeners added to the CCombo but
>> are never removed from the CCombo would it not cause some sort of memory
>> leak?
>>
>> code snippet of the createControl method:
>> comboBox.addKeyListener(new KeyAdapter() {
>> // hook key pressed - see PR 14201 public void
>> keyPressed(KeyEvent e) {
>> keyReleaseOccured(e);
>> }
>> });
>>
>> I am just wondering if this is a problem or do the listeners get
>> disposed once th e CCombo is disposed?
>>
>>
> If the method keyReleaseOccured() is in the same Class, then no memory
> leak occurs (the listener is just a java class which needs not to
> dispose something and is normally garbage collected) and the listener is
> automatically removed, because if the CCombo is disposed, the list of
> listeners is disposed and therefore the KeyAdapter which sends events to
> the enclosing class (CCombo).
> Sorry if the above is hard to get. It's not my best english :)
> Markus Wolf
Danke fur deine antwort. Es hat mich geholfen.
Vielen Dank Markus.
|
|
|
Powered by
FUDForum. Page generated in 0.03641 seconds