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

Bug 498199

Summary: FXCanvasEx does not free all resources when being disposed.
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF FXAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.0.0   
Target Milestone: 4.1.0 (Neon.1) M1   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2016-07-20 09:53:22 EDT
FXCanvasEx registers a traversal listener within its constructor, which is not unregistered within dispose. We need to fix this to prevent memory leaks.
Comment 1 Alexander Nyßen CLA 2016-07-20 10:11:11 EDT
In addition, as the scene reference is not removed, the cursorChangeListener is also not unregistered. Probably, dispose() should include a setScene(null) call.
Comment 2 Alexander Nyßen CLA 2016-07-20 10:33:45 EDT
(In reply to Alexander Nyßen from comment #1)
> In addition, as the scene reference is not removed, the cursorChangeListener
> is also not unregistered. Probably, dispose() should include a
> setScene(null) call.

unhookViewers() within AbstractFXView and AbstractFXEditor should already clear the scene. FXCanvas could do it if scene is not already cleared.
Comment 3 Alexander Nyßen CLA 2016-07-20 10:51:12 EDT
It seems FXCanvas registers a dispose listener, so clearing the scene from within unhook viewers may not be the way to go.
Comment 4 Alexander Nyßen CLA 2016-07-21 04:18:19 EDT
I pushed the following changes to origin/master and origin/R4_0_maintenance:

- Replaced FXCanvasEx.dipose() (which is still preserved because of API compatiblity reasons) with dispose listener.
- Ensured scene is unset when being disposed, to cursorChangeListener and event dispatcher are properly unregistered.
- Changed implementation of RedrawingEventDispatcher to better encapsulate that it wraps the 'original' event dispatcher. Ensured that it is properly disposed as well.
- Ensured SWT2FXEventConverter clears all its fields when being disposed.

Resolving as fixed in 4.1.0 M1.