Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332141

Summary: NotesView adds dispose listener to one widget then removes it from another
Product: [Tools] MAT Reporter: Remy Suen <remy.suen>
Component: GUIAssignee: Project Inbox <mat.gui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andrew_johnson
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Remy Suen CLA 2010-12-08 10:41:09 EST
In createPartControl(Composite), a DisposeListener is added to the provided parent composite.

In dispose(), the listener is then removed from the part site's shell.

The two controls are _not_ the same. There is no point in removing the listener from the shell because the shell didn't even have the listener in the first place. Also, the listeners are effectively destroyed/unreferenced when the widget is disposed so there really is no need for your code to even bother removing the listener.
Comment 1 Andrew Johnson CLA 2010-12-10 09:47:44 EST
Thanks for the report.
We could save the parent in the constructor, then check for !isDisposed() before doing the remove.
It does appear that the parent composite has already been disposed, so it is too late to remove the dispose listener, so there isn't any point in doing the remove.
I'll just remove it with a comment.
Comment 2 Andrew Johnson CLA 2010-12-10 09:53:10 EST
I've removed the removeDisposeListener call.
How did you spot the error? Have you seen other problems?
Comment 3 Remy Suen CLA 2010-12-10 10:02:57 EST
(In reply to comment #2)
> I've removed the removeDisposeListener call.

Thank you for your speedy response, Andrew.

> How did you spot the error?

I spotted the error while I was testing MAT on the Eclipse 4.1 SDK builds (see bug 332139). We don't have everything implemented yet so your getSite().getShell() call was actually causing an NPE (see bug 332140, that's a bug on our side that I will be fixing). I then looked at your code and noticed the strange pattern so I thought I'd raise it to your attention.

> Have you seen other problems?

Not yet...but I don't really know how to use MAT so I'm pretty sure I'm not really exercising it fully on 4.1 I don't think. :P