This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 193219 - DialogDisplayer leaks ActionListeners in option2Button
Summary: DialogDisplayer leaks ActionListeners in option2Button
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Dialogs&Wizards (show other bugs)
Version: 7.0
Hardware: PC All
: P4 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 10:29 UTC by emi
Modified: 2011-10-19 14:20 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Remove (duplicate) option listeners (2.06 KB, patch)
2010-12-10 10:37 UTC, emi
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description emi 2010-12-10 10:29:38 UTC
I'm using the Trivial implementation of DialogDisplayer and I've noticed that option2Button leaks listeners.

The problem happens if 'option instanceof AbstractButton' when a listener (created by makeListener(...)) is added and re-added without ever being removed.

See my attached patch for a possible way to fix this.
Comment 1 emi 2010-12-10 10:37:06 UTC
Created attachment 103926 [details]
Remove (duplicate) option listeners
Comment 2 Stanislav Aubrecht 2011-10-18 13:35:30 UTC
i did some profiling but there was no memory leak.
can you pls provide some sample code demonstrating how you use the Trivial dialog displayer?
thanks
Comment 3 emi 2011-10-18 13:54:09 UTC
StandardDialog uses NotifyDescriptor.getOptions and does:

buttonPanel.add(option2Button(options[i], nd, makeListener(options[i]), rp));

and if "option instanceof AbstractButton" then it just adds a fresh listener each time.

So, calling multiple times Trivial.notify(NotifyDescriptor nd) on the same NotifyDescriptor that has some AbstractButton options, will add as many listeners.
Comment 4 Stanislav Aubrecht 2011-10-18 14:55:02 UTC
core-main 1b48b935fd5d

thanks for the patch, i've modified it a bit though
Comment 5 emi 2011-10-18 15:15:56 UTC
I think you've accidentally commented Lookup.getDefault ().lookup (DialogDisplayer.class) and forced only the Trivial.
Comment 6 Stanislav Aubrecht 2011-10-18 15:21:10 UTC
(In reply to comment #5)
> I think you've accidentally commented Lookup.getDefault ().lookup
> (DialogDisplayer.class) and forced only the Trivial.

good catch, thanks!
i've just fixed it
Comment 7 Quality Engineering 2011-10-19 14:20:30 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/1b48b935fd5d
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #193219 - memory leak in Trivial DialogDisplayer