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

Bug 494320

Summary: Infinite loop in GeometryNode class
Product: [Tools] GEF Reporter: Xavier JACQUES <xavier.jacques.external>
Component: GEF GeometryAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: nyssen
Version: unspecified   
Target Milestone: 4.0.0 (Neon) RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Xavier JACQUES CLA 2016-05-23 10:50:52 EDT
I'm trying to upgrade my application to new GEF4 4.0.0RC1 (2016/05/18).

I'm falling into infinite loop at the line 648 of GeometryNode class

geometryProperty.set(((IScalable<T>) geometry).getScaled(sx, sy,		geometricBounds.getX(), geometricBounds.getY()));

because the getScaled method of the BezierCurve class is calling itself and makes an infinite recursion.

public BezierCurve getScaled(double fx, double fy, double cx, double cy) {
		return getCopy().getScaled(fx, fy, cx, cy);
	}



In the last version, the line causing problem in GeometryNode class was

((IScalable<T>) geometry).scale(sx, sy, geometricBounds.getX(),
						geometricBounds.getY());

and it worked like a charm.
Comment 1 Alexander Nyßen CLA 2016-05-23 12:10:13 EDT
We have revised GeometryNode to extend Region instead of Group (see #494021 for details), to finally get rid of the deprecated JavaFX method call that was still contained. 

To properly react to resize of geometry, we had to change the implementation to not resize the geometry in place, but to set a resized geometry (so the listener can update the shape). 

Unfortunately, the implementation of the BezierCurve.getScaled() operations is indeed wrong. It should be getCopy().scale() in all cases.
Comment 2 Alexander Nyßen CLA 2016-05-23 12:18:58 EDT
I pushed the following changes to origin/master:

- Ensured all getScaled() methods in BezierCurve to not call getScaled recursively, but instead call scale() on the created copy.
- Added as test case that confirms the correct behavior (no stack overflow occurs). 

This should resolved the issue you reported. Resolved as fixed in 4.0.0 RC2, which will be promoted today.

Xavier, please consume the RC2 build (I will announce its promotion via the gef-dev mailing list this evening) and confirm that the behavior is now proper (please re-open if not).
Comment 3 Xavier JACQUES CLA 2016-05-24 03:37:39 EDT
Thank you for your reactivity. It works perfectly with RC2.