From b2f6d73d1e080604eca5686f7f4e4c0d37670d64 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Mon, 4 Jan 2016 18:11:35 -0500 Subject: [PATCH] tmf: Avoid recursion in AbstractSegmentStoreTableViewer pack listener 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 Reviewed-on: https://git.eclipse.org/r/63513 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- .../views/segmentstore/AbstractSegmentStoreTableViewer.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java index 018fb46401..ae868e7606 100644 --- a/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java +++ b/analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java @@ -363,6 +363,7 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView // ------------------------------------------------------------------------ // Helper methods // ------------------------------------------------------------------------ + /* * Add the listener for SetData on the table */ @@ -370,14 +371,15 @@ public abstract class AbstractSegmentStoreTableViewer extends TmfSimpleTableView 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); } } }); -- 2.34.1