tmf: Update the initial item height calculation in Linux
authorBernd Hufmann <Bernd.Hufmann@ericsson.com>
Fri, 11 Sep 2015 18:57:24 +0000 (14:57 -0400)
committerBernd Hufmann <bernd.hufmann@ericsson.com>
Mon, 14 Sep 2015 10:29:59 +0000 (06:29 -0400)
In Linux the item height is calculated by the difference of the y
positions of 2 first consecutive tree items. When the 2 tree items
are available a paint listener is added to the tree and in the paint
method the height is calculated using the 2 stored items. The
paint listener is needed to make sure that the items are painted
and the y values are correct. However, between the time the items are
retrieved and the paint listener is executed the first item could have
been expanded and the y position second item is changed so that the
calculated height is much bigger. This patch fixes it by retrieving
the items in the paint listener.

Up to now this condition happens very, very rarely. However, with
patch https://git.eclipse.org/r/#/c/55749 this will happen consistently

Change-Id: I528c9baa5602cf8897ff84dc98cf71be2fb1fb91
Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/55779
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/TimeGraphCombo.java

index 95156b56e2d206db343d6de53f580c1b3cd7c28e..af6b2c7cf175510bd6d8d61b4dff040c297014d1 100644 (file)
@@ -1123,13 +1123,18 @@ public class TimeGraphCombo extends Composite {
             if (fLinuxItemHeight != 0) {
                 return fLinuxItemHeight;
             }
             if (fLinuxItemHeight != 0) {
                 return fLinuxItemHeight;
             }
-            List<TreeItem> treeItems = getVisibleExpandedItems(tree, true);
-            if (treeItems.size() > 1) {
-                final TreeItem treeItem0 = treeItems.get(0);
-                final TreeItem treeItem1 = treeItems.get(1);
+
+            if (getVisibleExpandedItems(tree, true).size() > 1) {
                 PaintListener paintListener = new PaintListener() {
                     @Override
                     public void paintControl(PaintEvent e) {
                 PaintListener paintListener = new PaintListener() {
                     @Override
                     public void paintControl(PaintEvent e) {
+                        // get the treeItems here to have all items
+                        List<TreeItem> treeItems = getVisibleExpandedItems(tree, true);
+                        if (treeItems.size() < 2) {
+                            return;
+                        }
+                        final TreeItem treeItem0 = treeItems.get(0);
+                        final TreeItem treeItem1 = treeItems.get(1);
                         tree.removePaintListener(this);
                         int y0 = treeItem0.getBounds().y;
                         int y1 = treeItem1.getBounds().y;
                         tree.removePaintListener(this);
                         int y0 = treeItem0.getBounds().y;
                         int y1 = treeItem1.getBounds().y;
This page took 0.02564 seconds and 5 git commands to generate.