Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317051

Summary: reducing item count can send Selection event
Product: [Eclipse Project] Platform Reporter: Grant Gayed <grant_gayed>
Component: SWTAssignee: Scott Kovatch <skovatch>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.6   
Target Milestone: 3.6.1   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Grant Gayed CLA 2010-06-16 10:52:29 EDT
- happens only on Table, not on Tree
- run the snippet below, wait for a few seconds, and you'll see that a Selection event is received when the Table's item count is set to 4
  -> on win32 and gtk this Selection event does not happen (haven't tried Carbon)
- it may be another case of ignoreSelect = true/false needed around noteNumberOfRowsChanged() invocation

public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setBounds(200, 200, 200, 200);
    shell.setLayout(new FillLayout());
    final Table table = new Table(shell, SWT.MULTI);
    for (int i = 0; i < 9; i++) {
    	new TableItem(table, SWT.NONE).setText("hi " + i);
    }
    shell.open();
    table.selectAll();
    table.addListener(SWT.Selection, new Listener() {
		public void handleEvent(Event event) {
			System.out.println("selection");
		}
	});
    display.timerExec(3333, new Runnable() {
		public void run() {
			table.setItemCount(4);
		}
	});
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}
Comment 1 Scott Kovatch CLA 2010-06-16 13:44:21 EDT
Good catch. List has a similar problem, but only when you remove the last item from the list.
Comment 2 Scott Kovatch CLA 2010-06-16 18:37:19 EDT
Patch is in bug 317054.
Comment 3 Scott Kovatch CLA 2010-06-28 13:02:36 EDT
Fixed in HEAD and R3_6 branch > 20100628.