Bug 549626 - SWTGraphics constructor has race condition when taking Clipping from GC with a set Transform
Summary: SWTGraphics constructor has race condition when taking Clipping from GC with ...
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.11.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-29 07:19 EDT by Attila Török CLA
Modified: 2019-07-29 07:26 EDT (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 Attila Török CLA 2019-07-29 07:19:11 EDT
When running the following code fragment in rapid succession (in a PaintListener for example):

     Image image = new Image(Display.getCurrent(), 100, 100);
     GC imageGC = new GC(image);

     Transform transform = new Transform(imageGC.getDevice());
     transform.translate(10, 10);
     imageGC.setTransform(transform);
     imageGC.setClipping(20, 20, 30, 30);
     SWTGraphics g = new SWTGraphics(imageGC);
     Rectangle r = new Rectangle();
     g.getClip(r);
     System.out.println(r.toString());

The printed rectangle randomly oscillates between two values:

Rectangle(20.0, 20.0, 30.0, 30.0)
Rectangle(20.0, 20.0, 10.0, 30.0)

It looks like some sort of a race condition.
The graphics painted onto the Image through g are also incorrectly clipped most of the time.
Manually overwriting the clipping on the SWTGraphics after it is constructed solves the issue:

    g.setClip(new Rectangle(20, 20, 30, 30));
Comment 1 Attila Török CLA 2019-07-29 07:22:33 EDT
The problem was not present with the GTK2 SWT backend, only appears with the GTK3 backend.