Project: SWT
Bug 317051 reducing item count can send Selection event
Reported: 2010-06-16 10:52:29 | Status: resolved fixed

- 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(); }

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/List.java bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Table.java bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Tree.java