Bug 563391

Summary: [GTK] Tree and Table items lose custom foreground colors when any of MeasureItem, EraseItem or PaintItem are registered
Product: [Eclipse Project] Platform Reporter: Javier Martin <habbit89>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: loskutov
Version: 4.12Keywords: regression
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Example showing the bug for Tree
none
The result in SWT 4.11, looking as expected
none
Result in SWT 4.12 when the bug is triggered (no foreground colors at all)
none
Result in both versions when the Tree does not have an EraseItem listener none

Description Javier Martin CLA 2020-05-20 05:47:38 EDT
Created attachment 282950 [details]
Example showing the bug for Tree

Expected behaviour:
- Foreground colors for each row (or cell) can be set when creating the Tree/TableItem instances ("static").
- Furthermore, the colors can also be set as late as inside the handler for the EraseItem event ("dynamic").

Actual behaviour:
- In SWT 4.11: works in Windows and x86-64 Linux
- In SWT 4.12 and above: Works in Windows but fails in x86-64 Linux.
  * Custom background colors (both statically and dynamically set) still work
  * Custom foreground colors are lost entirely, even if the event handler does not actually do anything. As soon as a listener for any of MeasureItem, EraseItem or PaintItem is registered, the custom foreground is ignored and the text is black.

The attached example shows the problem with the Tree widget, but the exact same occurs with Table - I can attach its own example if needed. If the listener is not added to the widget, colors that are set "statically" work in all cases. If it is added, everything works on SWT 4.11 (or later versions in Windows), but in Linux with SWT>=4.12 only the background is customized.

Environment info: Ubuntu 18.04
org.eclipse.swt.internal.deviceZoom=100
org.eclipse.swt.internal.gdk.backend=x11
org.eclipse.swt.internal.gtk.theme=Ambiance
org.eclipse.swt.internal.gtk.version=3.22.30
Comment 1 Javier Martin CLA 2020-05-20 07:55:03 EDT
Created attachment 282953 [details]
The result in SWT 4.11, looking as expected
Comment 2 Javier Martin CLA 2020-05-20 07:55:40 EDT
Created attachment 282954 [details]
Result in SWT 4.12 when the bug is triggered (no foreground colors at all)
Comment 3 Javier Martin CLA 2020-05-20 07:57:05 EDT
Created attachment 282955 [details]
Result in both versions when the Tree does not have an EraseItem listener

In this case, the foreground colors set "statically" (outside the listener) render correctly in the newer versions too.
Comment 4 Javier Martin CLA 2021-07-28 05:23:20 EDT
Bug is still present in SWT 4.20 on Gtk, reproducible with the same originally-attached example code. Background colours work, but the moment the listener is attached, all foreground colours stop working, no matter if they were set before the listener or inside it.

Environment info: Debian 10, using the Eclipse 2021-06-bundled JustJ JRE16.
org.eclipse.swt.internal.deviceZoom=100
org.eclipse.swt.internal.gdk.backend=x11
org.eclipse.swt.internal.gtk.theme=Adwaita
org.eclipse.swt.internal.gtk.version=3.24.5
org.eclipse.swt.internal.webkitgtk.version=2.32.1