From e80f56a645f98570ead038096a8963c0c2af4b05 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Tue, 10 Mar 2020 16:25:39 +0200 Subject: [PATCH] Fix regression in synchronization of updates gitlab #92 * Too much locking of syncMutex in AbstractVTKNodeMap::update() Change-Id: Iccfe4063076eb8e205511581d6b7d252142d7014 --- .../g3d/vtk/common/AbstractVTKNodeMap.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java index ba62ddbf..bc7c3552 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/common/AbstractVTKNodeMap.java @@ -372,12 +372,14 @@ public abstract class AbstractVTKNodeMap 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 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 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 n : removed) { @@ -460,7 +467,6 @@ public abstract class AbstractVTKNodeMap 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) { -- 2.47.1