tmf: Bug 496504: Fix duplicate child entries in Control Flow view
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / widgets / timegraph / model / TimeGraphEntry.java
index 8f36276a5ef45b8f47e970872b4e649b308b8abc..5d06e922121d4da7b2e07eda1199da8dea7fdb77 100644 (file)
@@ -262,9 +262,8 @@ public class TimeGraphEntry implements ITimeGraphEntry {
      *            The child entry
      */
     public synchronized void addChild(@NonNull TimeGraphEntry child) {
-        child.setParent(this);
         if (fComparator == null) {
-            fChildren.add(child);
+            addChild(fChildren.size(), child);
         } else {
             int i;
             for (i = 0; i < fChildren.size(); i++) {
@@ -273,7 +272,7 @@ public class TimeGraphEntry implements ITimeGraphEntry {
                     break;
                 }
             }
-            fChildren.add(i, child);
+            addChild(i, child);
         }
     }
 
@@ -287,6 +286,12 @@ public class TimeGraphEntry implements ITimeGraphEntry {
      * @since 2.0
      */
     public synchronized void addChild(int index, @NonNull TimeGraphEntry child) {
+        if (child.getParent() == this) {
+            return;
+        }
+        if (child.getParent() != null) {
+            child.getParent().removeChild(child);
+        }
         child.setParent(this);
         fChildren.add(index, child);
     }
@@ -299,7 +304,9 @@ public class TimeGraphEntry implements ITimeGraphEntry {
      * @since 2.0
      */
     public synchronized void removeChild(@NonNull TimeGraphEntry child) {
-        child.setParent(null);
+        if (child.getParent() == this) {
+            child.setParent(null);
+        }
         fChildren.remove(child);
     }
 
This page took 0.025411 seconds and 5 git commands to generate.