From: Reino Ruusu Date: Tue, 10 Mar 2020 14:25:39 +0000 (+0200) Subject: Fix regression in synchronization of updates X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=ee537f18773067782efc56c2facf8d85294fe628;p=simantics%2F3d.git Fix regression in synchronization of updates gitlab #92 * Too much locking of syncMutex in AbstractVTKNodeMap::update() Change-Id: Iccfe4063076eb8e205511581d6b7d252142d7014 (cherry picked from commit e80f56a645f98570ead038096a8963c0c2af4b05) --- 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) {