Community
Participate
Working Groups
Created attachment 202568 [details] Screenshot of blank data in virtual tree produced by snippet. Build id: I20110613-1736 (Linux 32 bit, libgtk2.0-0: 2.20.1-0ubuntu2) It seems that when tree elements are collapsed in a virtual tree and the scroll position is reset in the viewport, the items that became visible do not trigger an update, leaving them blank. To reproduce the problem: 1) Run the snippet below. 2) Scroll to bottom of tree. 3) Press refresh button 4) Press the collapse button. This snippet is a modified version of the virtual tree swt snippet. The refresh and collapse buttons perform the equivalent operations as the jface TreeViewer ones. public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout (new GridLayout()); final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER); tree.addListener(SWT.SetData, new Listener() { public void handleEvent(Event event) { TreeItem item = (TreeItem)event.item; TreeItem parentItem = item.getParentItem(); String text = null; if (parentItem == null) { text = "node "+tree.indexOf(item); } else { text = parentItem.getText()+" - "+parentItem.indexOf(item); } item.setText(text); item.setItemCount(10); } }); tree.setItemCount(20); tree.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL)); Button refresh = new Button(shell, SWT.PUSH); refresh.setText("refresh"); refresh.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { tree.clearAll(true); } }); refresh.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Button collapse = new Button(shell, SWT.PUSH); collapse.setText("collapse"); collapse.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } public void widgetSelected(SelectionEvent e) { collapse(tree, tree); } }); collapse.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose (); } private static void collapse(Tree tree, Widget widget) { if (widget instanceof Item) { Item item = (Item) widget; setExpanded(tree, item, false); } Item[] children = getChildren(widget); if (children != null) { for (int i = 0; i < children.length; i++) { collapse(tree, children[i]); } } } private static void setExpanded(Tree tree, Item node, boolean expand) { ((TreeItem) node).setExpanded(expand); // force repaints to happen tree.update(); } private static Item[] getChildren(Widget o) { if (o instanceof TreeItem) { return ((TreeItem) o).getItems(); } if (o instanceof Tree) { return ((Tree) o).getItems(); } return null; } }
Arun, can you please try that.
(In reply to comment #0) > To reproduce the problem: > > 1) Run the snippet below. > 2) Scroll to bottom of tree. > 3) Press refresh button > 4) Press the collapse button. > Oops, I forgot a step: after scrolling to bottom of the tree (step 2) expand some elements 2 levels down and scroll down again.
I have been able to reproduce the bug, will look into it.
Arun, Felipe - any update on this ? - It looks like this problem creates a major issue with Platform/Debug in the Variables view.
I think something is missing from the attached snippet as you were able to run it but when we tried it here on our GTK we got the trace below after following your instructions. (It also fails on Windows). The trace is reasonable as the tree has unlimited depth... Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(Arrays.java:3209) at java.lang.String.<init>(String.java:215) at java.lang.StringBuilder.toString(StringBuilder.java:430) at org.eclipse.swt.snippets.Snippet$1.handleEvent(Snippet.java:34) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4135) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465) at org.eclipse.swt.widgets.Tree.checkData(Tree.java:319) at org.eclipse.swt.widgets.TreeItem.getItems(TreeItem.java:782) at org.eclipse.swt.snippets.Snippet.getChildren(Snippet.java:100) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:84) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87) at org.eclipse.swt.snippets.Snippet.collapse(Snippet.java:87)
Created attachment 210026 [details] Updated example with limited depth.
(In reply to comment #5) > I think something is missing from the attached snippet as you were able to run > it but when we tried it here on our GTK we got the trace below after following > your instructions. (It also fails on Windows). The trace is reasonable as the > tree has unlimited depth... In some ways the OutOfMemory error is even more disturbing because it would mean that when you run the example there are many levels of items being materialized instead of just the visible ones. I was still able to run the example unmodified (with I20120123-2200), but I did attach a modified version which limits the tree depth to 2. I also get a bunch of the following exceptions in my console when I run the example: (SWT:4349): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(In reply to comment #7) > (SWT:4349): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT > (object)' failed I actually seem to get these even with the plain snippet: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet202.java
Fixed both the redraw problems and the warnings. http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=5dc68b1cb799fd3d7f3b8218db3d623442a9221c The OutOfMemory is a problem in the example, it is creating all the items by calling getItems(). This is expected behaviour.
Whow ! Thanks for the quick turnaround. Could this be backported to 3.7.2 ? As it affects our product. Many Thanks! Martin
I am sorry. The fix needs more testing and 3.7.2 RC3 is next week.
(In reply to comment #9) > Fixed both the redraw problems and the warnings. Thank You! (Fixed in M5 I assume) > The OutOfMemory is a problem in the example, it is creating all the items by > calling getItems(). This is expected behaviour. Any idea why I don't observe this error on my system then?
*** Bug 356415 has been marked as a duplicate of this bug. ***
(In reply to comment #12) > (In reply to comment #9) > > Fixed both the redraw problems and the warnings. > Thank You! (Fixed in M5 I assume) > Yes > > The OutOfMemory is a problem in the example, it is creating all the items by > > calling getItems(). This is expected behaviour. > Any idea why I don't observe this error on my system then? I am not sure, but it is probably because SWT.SetData is not sent synchronous in your system when the example calls getItems() or setExpanded().
CQ:WIND00295043