Community
Participate
Working Groups
Created attachment 262126 [details] Test case for GC#getClipping bug GC#getClipping returns an empty [0, 0, 0, 0] clipping on CentOS 6. This bug is present with Eclipse 4.4, 4.5 and 4.6. I didn't test other versions. I've reports of this bug from actual CentOS 6 users. The exact GTK version that is being used with latest updates is 2.24.23. Note that CentOS 6 is being fully supported until Q2 2017, and will get maintenance updates till 30 November 2020, so this version of GTK should be supported properly by SWT. The exact code where the problem occurs is in GC#getSize, in the following if fragment: if (OS.GTK_VERSION >= OS.VERSION(2, 24, 0)) { width[0] = OS.gdk_window_get_width(data.drawable); height[0] = OS.gdk_window_get_height(data.drawable); } else { OS.gdk_drawable_get_size(data.drawable, width, height); } The "then" part of this if condition is being executed and returns an empty size. The "else" part actually returns the correct size, but version 2.24.23 doesn't fall there. This bug affects GEF-based plugins that use it to draw to an SWT Image. It might be the same problem as described in Bug 489741. I'm attaching a snippet that reproduces this issue. The following code will cause the test case to draw a black rectangle on faulty systems: Rectangle clip = gc.getClipping(); gc.setClipping(clip); On supported system it will draw a red rectangle.
In the case of Eclipse 4.7 (Oxygen), the code is changed to if (data.drawable != 0) { width[0] = OS.gdk_window_get_width(data.drawable); height[0] = OS.gdk_window_get_height(data.drawable); return; } So, Eclipse 4.7 still has same problem. In the case of Eclipse 4.3, the OS.USE_CAIRO becomes true on the CentOS 6 environment, and data.drawable is 0. so Eclipse 4.3 skips the above code and runs GC#getClipping() correctly. (Eclipse 4.3 does not check CAIRO version and set the OS.USE_CAIRO only with GTK version.)
OS.gdk_drawable_get_size(data.drawable, width, height); has already removed from Eclipse 4.7. Instead of that, OS.gdk_pixmap_get_size(data.drawable, width, height); works fine in this case.
We have got the same issue with a rich Eclipse RCP client based on Eclipse 4.7.1. Thanks to Peter for opening this bug and to Nobuhiko for providing the workaround, that works fine on RHEL/CentOS 6 but not on RHEL7 (but GC#getClipping() is working on RHEL 7). But the use of OS#methods being discouraged, will this bug be corrected in a future release of SWT ?
Is this still reproducible on GTK3.22 and 4.8?
(In reply to Eric Williams from comment #4) > Is this still reproducible on GTK3.22 and 4.8? No response in awhile, please reopen this ticket if the issue reproduces on GTK3.22 with 4.9 or 4.10.