[Gtk] Fix Tree preferred size becoming invisible after style toggle#3309
[Gtk] Fix Tree preferred size becoming invisible after style toggle#3309akurtakov wants to merge 1 commit into
Conversation
When a Tree with no explicit columns is laid out with SWT.DEFAULT size hints (e.g. GridData(SWT.DEFAULT, SWT.DEFAULT)), the GTK preferred-size call on the not-yet-rendered GtkTreeView returns width 0. The resulting zero-width allocation triggers the ZERO_WIDTH hide path, making the widget invisible.
|
Fixes #3025 |
|
This is alternative fix for a similar problem to https://bugs.eclipse.org/bugs/show_bug.cgi?id=465056 but more dynamic. I'll switch Table to this approach too when we open next stream. |
HeikoKlare
left a comment
There was a problem hiding this comment.
I can reproduce the issue reported in #3025 and can confirm that this change fixes the issue. I've tested on a WSL system.
The code itself also looks functionally sound to me. I just wonder if this iteration of tree items at OS level may have a performance impact. I remember mentions of performance issues of trees on GTK in the past. And we are currently investigating some issues on Windows where retrieving tree items from the OS is very expensive, such that we try to replace the code with the usage of SWT metadata.
In case we are sure there is no risk of performance issue with this, I leave it up to your judgement whether it is still safe to do for RC1.
|
In theory this PR can introduce performance costs, but only in a very specific scenario: a single‑column Tree with a very large number of root items (2K+), and only when GTK reports width = 0. I haven't seen such case in the wild. |
|
@iloveeclipse As https://bugs.eclipse.org/bugs/show_bug.cgi?id=465056 was reported by you and this one is almost identical wdyt, should we push it for RC1? |
|
I would wait for 4.41, it is not a recent regression. |
There was a problem hiding this comment.
Pull request overview
Fixes a GTK-specific issue where a Tree with no explicit columns and SWT.DEFAULT size hints could compute a preferred width of 0 (because the GtkTreeView had not yet been rendered), causing the ZERO_WIDTH hide path to make the widget invisible. The fix computes the width directly from cell renderers of root items as a fallback.
Changes:
- In
Tree.computeSizeInPixels, whenwHint == SWT.DEFAULT, nativesize.x == 0, and no explicit columns exist, iterate the root items and usecalculateWidthon the first column to derive a non-zero preferred width.
When a Tree with no explicit columns is laid out with SWT.DEFAULT size hints (e.g. GridData(SWT.DEFAULT, SWT.DEFAULT)), the GTK preferred-size call on the not-yet-rendered GtkTreeView returns width 0. The resulting zero-width allocation triggers the ZERO_WIDTH hide path, making the widget invisible.