Fix for bug 382529: ConcurrentModificationException in Control Flow
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowView.java
index bf905ac1669c56435bf4371f8ee5a2ff7f570dfc..e68580b1b344da958d7909ffa95fdc8fdcc02272 100644 (file)
@@ -110,6 +110,9 @@ public class ControlFlowView extends TmfView {
     // The timegraph entry list\r
     private ArrayList<ControlFlowEntry> fEntryList;\r
 \r
+    // The time graph entry list synchronization object\r
+    final private Object fEntryListSyncObj = new Object();\r
+\r
     // The start time\r
     private long fStartTime;\r
 \r
@@ -258,7 +261,10 @@ public class ControlFlowView extends TmfView {
 \r
         @Override\r
         public void run() {\r
-            ArrayList<ControlFlowEntry> entryList = fEntryList;\r
+            ArrayList<ControlFlowEntry> entryList = null;\r
+            synchronized (fEntryListSyncObj) {\r
+                entryList = fEntryList;\r
+            }\r
             if (entryList == null) {\r
                 return;\r
             }\r
@@ -574,7 +580,9 @@ public class ControlFlowView extends TmfView {
                 buildTree(entryList, rootList);\r
             }\r
             Collections.sort(rootList, fControlFlowEntryComparator);\r
-            fEntryList = rootList;\r
+            synchronized (fEntryListSyncObj) {\r
+                fEntryList = (ArrayList<ControlFlowEntry>) rootList.clone();\r
+            }\r
             refresh(INITIAL_WINDOW_OFFSET);\r
         }\r
         for (ControlFlowEntry entry : rootList) {\r
@@ -661,7 +669,10 @@ public class ControlFlowView extends TmfView {
                 if (fTimeGraphCombo.isDisposed()) {\r
                     return;\r
                 }\r
-                ITimeGraphEntry[] entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                ITimeGraphEntry[] entries = null;\r
+                synchronized (fEntryListSyncObj) {\r
+                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                }\r
                 Arrays.sort(entries, fControlFlowEntryComparator);\r
                 fTimeGraphCombo.setInput(entries);\r
                 fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);\r
This page took 0.024687 seconds and 5 git commands to generate.