In the SWT.SetData listener TableColumn.pack() is called. This requires
all visible items from being filled in order to pack the column. For
each visible item a SWT.SetData event is fired which triggers another
TableColumn.pack().
In Windows, after 12 such iterations in the stack, the table somehow
behaves badly and the OS incorrectly returns an item count of zero,
which causes ArrayIndexOutOfBoundsException and other problems.
Since the intention is to pack the columns only once, the SWT.SetData
listener is removed before the pack instead of after the pack, thus
avoiding the recursive calls.
Change-Id: Id44c54a474ed6e04aa2d79c051d863011f55a8aa
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/63513
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
+
/*
* Add the listener for SetData on the table
*/
getControl().addListener(SWT.SetData, new Listener() {
@Override
public void handleEvent(@Nullable Event event) {
+ // Remove the listener before the pack
+ getControl().removeListener(SWT.SetData, this);
+
// Pack the column the first time data is set
TableViewer tableViewer = getTableViewer();
if (tableViewer != null) {
for (TableColumn col : tableViewer.getTable().getColumns()) {
col.pack();
}
- // Remove the listener after the pack
- getControl().removeListener(SWT.SetData, this);
}
}
});