Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332141 - NotesView adds dispose listener to one widget then removes it from another
Summary: NotesView adds dispose listener to one widget then removes it from another
Status: RESOLVED FIXED
Alias: None
Product: MAT
Classification: Tools
Component: GUI (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-08 10:41 EST by Remy Suen CLA
Modified: 2010-12-10 10:02 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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