Bug 198904 - [DataBinding] Listeners in swt Observables are not removed on dispose
Summary: [DataBinding] Listeners in swt Observables are not removed on dispose
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.3.1   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug
Depends on:
Blocks:
 
Reported: 2007-08-05 20:38 EDT by Ashley Cambrell CLA
Modified: 2007-09-08 23:56 EDT (History)
1 user (show)

See Also:


Attachments
Additional test cases and test method to test that dipose correctly cleans up listeners. (37.43 KB, patch)
2007-08-05 20:38 EDT, Ashley Cambrell CLA
no flags Details | Diff
Patch to overide dispose and clean up listeners (15.11 KB, patch)
2007-08-05 20:46 EDT, Ashley Cambrell CLA
no flags Details | Diff
combined patch (57.14 KB, patch)
2007-08-15 13:20 EDT, Boris Bokowski CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ashley Cambrell CLA 2007-08-05 20:38:23 EDT
Created attachment 75409 [details]
Additional test cases and test method to test that dipose correctly cleans up listeners.

Build ID: HEAD

Steps To Reproduce:
1. Apply patch that contains test cases for dispose methods.
2. Tests fail with a NullPointerException as the listeners try and fire events to bindings that have been disposed (realm is null, so it throws the NPE).
Comment 1 Ashley Cambrell CLA 2007-08-05 20:46:18 EDT
Created attachment 75410 [details]
Patch to overide dispose and clean up listeners

This patch modifies
* ComboSingleSelectionObservableValue
* TableSingleSelectionObservableValue
* CComboSingleSelectionObservableValue
* ListSingleSelectionObservableValue
* ComboObservableValue
* SpinnerObservableValue
* ListObservableValue
* ButtonObservableValue
* CComboObservableValue

the extracts listeners into a field so that they can be removed in an override dispose method.

Classes that extend SingleSelectionObservableValue could easily be refactored to avoid duplication.
Comment 2 Boris Bokowski CLA 2007-08-06 09:48:05 EDT
3.3.1 candidate?
Comment 3 Brad Reynolds CLA 2007-08-14 21:34:58 EDT
(In reply to comment #2)
> 3.3.1 candidate?
> 

+1
Comment 4 Boris Bokowski CLA 2007-08-15 13:20:21 EDT
Created attachment 76136 [details]
combined patch

Updated the class headers listing Ashley's contribution.

I noticed that the test and fix for bug 198903 is part of this patch as well, is this correct, Ashley? I'm fine with releasing this patch and marking the other bug as fixed at the same time, but would like you to double-check that this patch will also fix bug 198903.
Comment 5 Boris Bokowski CLA 2007-08-15 13:52:38 EDT
An exemplary bug report with test cases and a fix ready to go. Thanks a lot for your effort, Ashley!
Comment 6 Ashley Cambrell CLA 2007-08-15 18:37:59 EDT
I must have left the fix for bug 198903 in the patch. As it was a one liner, I didn't submit a patch for the other.

Not as I intended but the fix for bug 198903 is correct.

Thanks Boris
Comment 7 Boris Bokowski CLA 2007-08-16 17:04:50 EDT
Released to the 3.3 maintenance stream >20070816.
Comment 8 Boris Bokowski CLA 2007-09-06 13:20:21 EDT
Verified in M20070905-1045 and released to HEAD as well.
Comment 9 Brad Reynolds CLA 2007-09-08 23:56:34 EDT
Couple of quick comments...

1. Thank you for writing tests.
2. In my merge of bug 182059 to HEAD I removed the addition of AbstractSWTTestCase.notifySelection(Widget).  You can accomplish the same with widget.notifyListeners(SWT.Selection, null).  Also since our testing strategy is changing this won't be very useful as our code moves into the delegates.
3. I removed TestCounterValueChangeListener.  There was an existing class, ValueChangeEventTracker, that alreadys performed this function.  For future referenct there are trackers for the other event types as well.
4.  I removed some of the tests since our conformance tests cover the use cases.  I think we can add some dispose tests to the conformance test suite (bug 202735) to test all observables as well.

I just didn't want you to be surprised when you saw that some of this was removed.  Thanks again!