Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 265555 - [breadcrumb] opening drop down does not reveal and select current item
Summary: [breadcrumb] opening drop down does not reveal and select current item
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-19 17:04 EST by Natasha D'Silva CLA
Modified: 2009-07-29 14:07 EDT (History)
1 user (show)

See Also:


Attachments
Patch with fix. (3.03 KB, patch)
2009-02-25 13:56 EST, Pawel Piech CLA
no flags Details | Diff
Patch that adds a REVEAL flag. (4.50 KB, patch)
2009-03-19 00:00 EDT, Pawel Piech CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Natasha D'Silva CLA 2009-02-19 17:04:22 EST
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.
Comment 1 Natasha D'Silva CLA 2009-02-19 17:33:05 EST
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) {
				}
			}
		}
	}
}




Comment 2 Pawel Piech CLA 2009-02-24 01:00:44 EST
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.
Comment 3 Pawel Piech CLA 2009-02-24 17:42:06 EST
I can indeed reproduce it on XP, so I'll investigate it there.
Comment 4 Pawel Piech CLA 2009-02-25 13:35:39 EST
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 ();
}	
}

Comment 5 Pawel Piech CLA 2009-02-25 13:56:47 EST
Created attachment 126762 [details]
Patch with fix.
Comment 6 Pawel Piech CLA 2009-02-25 13:59:37 EST
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.
Comment 7 Natasha D'Silva CLA 2009-03-05 17:46:52 EST
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.
Comment 8 Pawel Piech CLA 2009-03-09 17:02:42 EDT
I'll investigate this after M6.
Comment 9 Pawel Piech CLA 2009-03-11 14:31:49 EDT
I re-tested this on Linux, and there it seems to consistently not reveal the selected item.  I must have missed something major...
Comment 10 Pawel Piech CLA 2009-03-19 00:00:57 EDT
Created attachment 129319 [details]
Patch that adds a REVEAL flag.

This takes care of the problem on Linux.
Comment 11 Pawel Piech CLA 2009-03-19 00:05:08 EDT
I applied the additional fix.  Darin please review.  Natasha, when you get a chance please confirm fix.  Thanks!
Comment 12 Darin Wright CLA 2009-07-29 14:07:14 EDT
Verified.