]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Node listeners were removed too soon. 51/3451/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 5 Nov 2019 14:28:18 +0000 (16:28 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 5 Nov 2019 14:28:18 +0000 (16:28 +0200)
Listener removal caused PipeRun splits to fail synchronization to DB.

As a precaution, now nodeAdded and nodeRemoved will synchronize both
parent and and actual node (previously only parent node was
synchronized).

gitlab #35

Change-Id: I34a105cc91b8b720a48a166288610debc10a3b84

org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java

index 2c37521b8367b751451d3a73c5b02cbca60977cd..bb5493f6b7a76ee806d712d402691f5b862cdc8d 100644 (file)
@@ -227,6 +227,7 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                        }
                        if (changeTracking) {
                                mapping.rangeModified((E)node.getParent());
+                               mapping.rangeModified((E)node);
                        }
                        added.add(new Pair<E, String>(node, id));
                        rangeModified = true;
@@ -242,8 +243,10 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                                if (n.first.equals(node))
                                        return;
                        }
-                       if (changeTracking && !db)
+                       if (changeTracking && !db) {
+                           mapping.rangeModified((E)node);
                                mapping.rangeModified((E)node.getParent());
+                       }
                        removed.add(new Pair<E, String>(node, id));
                        rangeModified = true;
                }
@@ -438,6 +441,7 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                for (E n : delete) {
                        if (DEBUG) System.out.println(debugString(n));
                        mapping.getRange().remove(n);
+                       stopListening(n);
                }
                delete.clear();
        }
@@ -623,7 +627,6 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                if (DEBUG) System.out.println("Node added " + child + " parent " + node);
                //receiveAdd((E)child, rel ,graphUpdates);
                receiveAdd((E)child, rel ,graphModified.contains(node));
-               
        }
        
        @SuppressWarnings("unchecked")
@@ -634,9 +637,10 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                //receiveRemove((E)child, rel, graphUpdates);
                receiveRemove((E)child, rel, graphModified.contains(node));
                
-               //FIXME : sometimes removed structural models cause ObjMap to add their children again.
-               //        removing the listener here prevents corruption of visual model, but better fix is needed.
-               stopListening(child);
+               //FIXME : 1. sometimes removed structural models cause ObjMap to add their children again.
+               //           removing the listener here prevents corruption of visual model, but better fix is needed.
+               //        2. detach causes nodeRemoved event, which then causes other critical events to be missed. Took out th 
+               //stopListening(child);
        }
        
        @Override