tmf.ui: fix UpdateThread's illegal thread access on updateData
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 21 Sep 2015 20:14:21 +0000 (16:14 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 25 Sep 2015 00:05:33 +0000 (20:05 -0400)
The method updateData should only be called from the UI thread. This
patch makes the update thread call a ui runnable to update the data.

Change-Id: If1336322a0be20213dd53e151d2e4707481610b7
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/56383
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-by: Hudson CI
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/viewers/xycharts/linecharts/TmfCommonXLineChartViewer.java

index 4f08c652aeb1ec91cf81ce71ee873f06d20428c2..56516dcdc68f31a692cf2ba77ec60b8482c37396 100644 (file)
@@ -114,15 +114,15 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                 initializeDataSource();
                 TmfUiRefreshHandler.getInstance().queueUpdate(TmfCommonXLineChartViewer.this,
                         new Runnable() {
-                            @Override
-                            public void run() {
-                                if (!getSwtChart().isDisposed()) {
-                                    /* Delete the old series */
-                                    clearContent();
-                                    createSeries();
-                                }
-                            }
-                        });
+                    @Override
+                    public void run() {
+                        if (!getSwtChart().isDisposed()) {
+                            /* Delete the old series */
+                            clearContent();
+                            createSeries();
+                        }
+                    }
+                });
             }
         };
         thread.start();
@@ -149,7 +149,12 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
 
         @Override
         public void run() {
-            updateData(getWindowStartTime(), getWindowEndTime(), fNumRequests, fMonitor);
+            Display.getDefault().syncExec(new Runnable() {
+                @Override
+                public void run() {
+                    updateData(getWindowStartTime(), getWindowEndTime(), fNumRequests, fMonitor);
+                }
+            });
             updateThreadFinished(this);
         }
 
@@ -364,8 +369,8 @@ public abstract class TmfCommonXLineChartViewer extends TmfXYChartViewer {
                     getSwtChart().redraw();
 
                     if (isSendTimeAlignSignals()) {
-                        // The width of the chart might have changed and its time
-                        // axis might be misaligned with the other views
+                        // The width of the chart might have changed and its
+                        // time axis might be misaligned with the other views
                         Point viewPos = TmfCommonXLineChartViewer.this.getParent().getParent().toDisplay(0, 0);
                         int axisPos = getSwtChart().toDisplay(0, 0).x + getPointAreaOffset();
                         int timeAxisOffset = axisPos - viewPos.x;
This page took 0.025667 seconds and 5 git commands to generate.