tmf: Avoid recursion in AbstractSegmentStoreTableViewer pack listener
authorPatrick Tasse <patrick.tasse@gmail.com>
Mon, 4 Jan 2016 23:11:35 +0000 (18:11 -0500)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 5 Jan 2016 20:22:00 +0000 (15:22 -0500)
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>
analysis/org.eclipse.tracecompass.analysis.timing.ui/src/org/eclipse/tracecompass/analysis/timing/ui/views/segmentstore/AbstractSegmentStoreTableViewer.java

index 018fb46401bfeb69226ccacfe22a00ebe3d3748f..ae868e76067070d4fbee0595c641e78a2b0fbb71 100644 (file)
@@ -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);
                 }
             }
         });
This page took 0.026746 seconds and 5 git commands to generate.