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

Bug 235814

Summary: Zest's GraphNode#initFigure() and Graph#registerItem() called twice unnecessarily
Product: [Tools] GEF Reporter: Stefan Tucker <stefan.tucker>
Component: GEF-Legacy ZestAssignee: Ian Bull <irbull>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse
Version: 3.4   
Target Milestone: 3.5.0 (Galileo) M3   
Hardware: PC   
OS: Windows Server 2003   
Whiteboard:

Description Stefan Tucker CLA 2008-06-05 09:34:39 EDT
Build ID: I20080523-0100

Steps To Reproduce:
1. Instantiate GraphNode(g, 0, "z")

2. GraphNode's ctor calls initModel()

3. That calls graph.registerItem(this)

4. That calls item.getFigure()

5. this.nodeFigure is null, so it calls initFigure() which calls createFigureForModel() and sets this.nodeFigure

6. It returns back up to the ctor, which promptly calls initFigure() (again), even though this.nodeFigure is already not null.

7. Finally, GraphNode's ctor calls registerItem(this) again. (initModel() called it already.)

More information:
I think these unnecessary allocations and calls, at the very least, affect performance and make Zest less efficient than it could be.

It also seems unusual for initFigure() to set this.nodeFigure as well as return it so that the caller can set this.nodeFigure (again).
Comment 1 Ian Bull CLA 2008-10-10 19:32:17 EDT
Thanks!

This was actually causing a pretty bad memory leak too.  I now set hte figure in initFigure, and only call register item in the constructor.