Bug 399281 - [visualizer] disposeVisualizer() is not getting called when visualizer view is close
Summary: [visualizer] disposeVisualizer() is not getting called when visualizer view i...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-debug-dsf-gdb (show other bugs)
Version: Next   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 8.2   Edit
Assignee: Marc Dumais CLA
QA Contact: Marc Khouzam CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-28 11:27 EST by Marc Dumais CLA
Modified: 2013-03-01 11:30 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Dumais CLA 2013-01-28 11:27:11 EST
The MulticoreVisualizer logic seems to rely on disposeVisualizer() being called when the visualizer view is disposed-of, to properly dispose of its objects.  It doesnt seem to be.

to reproduce: 
Set a breakpoint in MulticoreVisualizer:disposeVisualizer() and close the visualizer view.  The breakpoint does not seem to hit.

The problem seems to be in VisualizerViewer ; the dispose() method is apparently never called upon closing the Visualizer view.  That seemed strange, so we googled and found the following post, that seems to indicate that we would need to use a "DisposeListener" instead of relying on dispose() being called:

http://www.eclipse.org/forums/index.php/t/351342/
Comment 1 Marc Dumais CLA 2013-02-01 15:11:26 EST
Hi!

I now understand a bit more what was happening, I think.

VisualizerViewer is overriding the dispose() method of Widget, probably expecting that its own version of it would be called when the view is disposed.  But Widget does not recursively call the dispose() of its descendents, so the "cleanup chain" was broken at that level.  

Replacing the overridden dispose() by a disposeListener fixed that.

Then from there there were a few other little things that needed fixing for the disposal of the view and its objects to happen harmoniously.  

While I was there, I thought it would be a good thing to replace the overridden instances of dispose(), of Widget descendants, by a disposeListener (for classes MulticoreVisualizerCanvas, GraphicCanvas and BufferedCanvas).  
That was not strictly necessary but it removes the need for each derived class level to call its super.dispose() and also it can prevent a sequence problem : 

for things to work correctly, each level of descendant needs to do its own local cleanup before calling "super.dispose()", else there can be exceptions when trying to dispose of listeners and such, when the disposal happens after the call of Widget.dispose().  An example of this was happening in the dispose() of BufferedCanvas.

Hopefully all of this makes sense :)

Here is the proposed patch: 

https://git.eclipse.org/r/#/c/10113/

Thanks,

Marc

P.S. BTW the following article was very helpful to help me understand how the Widget dispose() should work:

http://www.eclipse.org/articles/swt-design-2/swt-design-2.html
Comment 2 Marc Dumais CLA 2013-02-01 15:11:43 EST
w/r to the patch submitted in this bug, I declare the following:

1) that I am authorized to submit this code change
2) that the code is 100% my own work

Marc Dumais
Comment 3 Marc Dumais CLA 2013-02-06 14:14:00 EST
Thanks Bill for the review and merging this into master.  I'll let you close the bug if you think it's resolved.  

How about also doing this fix in the 8.1 branch? 

Thanks,

Marc
Comment 4 William Swanson CLA 2013-02-06 14:42:05 EST
Fix reviewed and merged to master.
Comment 5 Marc Khouzam CLA 2013-02-08 10:32:37 EST
(In reply to comment #3)

> How about also doing this fix in the 8.1 branch? 

That would have been good, but we're on the last day for 8.1.2 and I don't think it is worth the risk to put in a late fix like that.  So, let's keep it in master only.