]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix regression in synchronization of updates 83/3983/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Tue, 10 Mar 2020 14:25:39 +0000 (16:25 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Tue, 10 Mar 2020 14:25:39 +0000 (16:25 +0200)
gitlab #92

* Too much locking of syncMutex in AbstractVTKNodeMap::update()

Change-Id: Iccfe4063076eb8e205511581d6b7d252142d7014

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

index ba62ddbfdb64ca14745420ec7d17b145a1e0ee06..bc7c35528fde4a33f07cc0c5755ecf27e781f1de 100644 (file)
@@ -372,12 +372,14 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
        private boolean useFullSyncWithUndo = false;
        
        protected void update(ReadGraph graph) throws DatabaseException {
-               synchronized (syncMutex) {
-                       if (DEBUG) System.out.println("Graph update start");
-                       
-                       if (runUndo && useFullSyncWithUndo) {
+               if (DEBUG) System.out.println("Graph update start");
+               
+               if (runUndo && useFullSyncWithUndo) {
+                       synchronized (syncMutex) {
                                reset(graph);
-                       } else {
+                       }
+               } else {
+                       synchronized (syncMutex) {
                                graphUpdates = true;
                                for (DBObject domainObject : mapping.getDomainModified()) {
                                        @SuppressWarnings("unchecked")
@@ -385,18 +387,24 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
                                        if (rangeObject != null)
                                                graphModified.add(rangeObject);
                                }
-                               mapping.updateRange(graph);
+                       
+                       }
+                       
+                       mapping.updateRange(graph);
+                       
+                       synchronized (syncMutex) {
                                graphModified.clear();
                                syncDeletes();
-                               clearDeletes();
-                               graphUpdates = false;
-               }
-                       
-                       if (mapping.isRangeModified() && !runUndo && !runRedo)
-                               commit((String)null);
+                       }
                        
-                       if (DEBUG) System.out.println("Graph update done");
+                       clearDeletes();
+                       graphUpdates = false;
                }
+               
+               if (mapping.isRangeModified() && !runUndo && !runRedo)
+                       commit((String)null);
+               
+               if (DEBUG) System.out.println("Graph update done");
        }
        
        @Override
@@ -438,7 +446,6 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
         * This code here synchronizes removed and added objects to collect deletable objects. (a deletable object is one which is removed but not added).  
         * 
         */
-       @SuppressWarnings("unused")
        protected void syncDeletes() {
                deleteUC.clear();
                for (Pair<E, String> n : removed) {
@@ -460,7 +467,6 @@ public abstract class AbstractVTKNodeMap<DBObject,E extends INode> implements VT
        /**
         * Clears deletable objects from mapping cache.
         */
-       @SuppressWarnings("unused")
        protected void clearDeletes() {
                if (DEBUG && delete.size() > 0) System.out.println("Delete");
                for (E n : delete) {