Community
Participate
Working Groups
Build ID: Build id: I20090202-1535 Steps To Reproduce: I have two debug sessions. A large one with many threads, say 70, and another one, launched after the large app. When debugging the second in breadcrumb mode, if I select a stackframe and open the drop down, all I see are the threads of the other app. I have to scroll to find it, and when I do, it isn't selected. I'm seeing this problem on Vista and XP.
Here's a simple application: public class LoopForever2 { public static void main(String[] args) { int count = -1; // BREAKPONT here for (int i=0; i<100; i++) { System.out.println(count); count--; } } } This bug can be reproduced by debugging the application above afterlaunching the app below: public class ManyThreads { public static void main(String[] args) { ManyThreads main = new ManyThreads(); main.createThreads(); } public synchronized void createThreads() { for (int i = 0; i < 70; i++) { new SleepThread().start(); } } //Each of these threads just sleeps and does nothing class SleepThread extends Thread { public void run() { for (int i=0; i<1000; i++) { try { sleep(i*1000); } catch (InterruptedException e) { } } } } }
Thank you for the code snippets and the instructions, unfortunately I'm still stuck not being able to reproduce this. Are there any more particular details steps to reproduce? Or is anyone else able to observe this problem as I must be missing something really obvious here. BTW I usually work in linux, tomorrow I'll try it out on XP.
I can indeed reproduce it on XP, so I'll investigate it there.
After a few hours of experimentation I was finally able to reproduce this problem with the snippet below. Calling shell.pack() seems to be the kiss of death. It temporarily resizes the tree to show all the elements, so that after the tree is resized back down the scroll position is pretty much random. I don't think there is an SWT bug here, because they claim they don't know what happens to the scroll position when you resize the control. import org.eclipse.swt.*; import org.eclipse.swt.layout.*; import org.eclipse.swt.widgets.*; public class bug265555 { public static void main(String[] args) { Display display = new Display(); final Shell shell = new Shell(display, SWT.RESIZE | SWT.TOOL | SWT.ON_TOP); GridLayout layout= new GridLayout(1, false); layout.marginHeight= 0; layout.marginWidth= 0; shell.setLayout(layout); Composite composite= new Composite(shell, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout gridLayout= new GridLayout(1, false); gridLayout.marginHeight= 0; gridLayout.marginWidth= 0; composite.setLayout(gridLayout); final Tree tree = new Tree(composite, SWT.VIRTUAL | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); 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(100); TreeItem item = tree.getItem(70); tree.setTopItem(item); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); shell.pack(); shell.setLocation(100, 100); shell.setSize(400, 400); shell.setVisible(true); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } shell.setSize(400, 300); display.dispose (); } }
Created attachment 126762 [details] Patch with fix.
I committed the fix. Darin, please review the changes, and Natasha if you have a chance, please verify the fix. I also found a few other disturbing issues while investigating this. One is a jface performance issue that I filed in bug 266189, the other seem to be windows and breadcrumb, so I'll file separate bugs for them.
I'm still seeing this problem. Try setting a breakpoint at line 18 of ManyThreads, and debugging. I changed the number of threads to 15 and the problem is still reproducible. When the threads stop at that location, and an arbitrary one is selected. Sometimes, when you open the drop down, everything works as expected, but sometimes the item is selected and possibly expanded in the popup, but it is not revealed. This is reproducible regardless of the 'auto expand' setting.
I'll investigate this after M6.
I re-tested this on Linux, and there it seems to consistently not reveal the selected item. I must have missed something major...
Created attachment 129319 [details] Patch that adds a REVEAL flag. This takes care of the problem on Linux.
I applied the additional fix. Darin please review. Natasha, when you get a chance please confirm fix. Thanks!
Verified.