X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.g3d.vtk%2Fsrc%2Forg%2Fsimantics%2Fg3d%2Fvtk%2Fcommon%2FAbstractVTKNodeMap.java;h=bc7c35528fde4a33f07cc0c5755ecf27e781f1de;hb=85bbf68087838bf65da8c7998a3b781ed5fb9fbd;hp=a42c367252fc0744a754cc22fbd9f9045f283275;hpb=da945733caf267fed4cf28206cc99f4f57fbd1e9;p=simantics%2F3d.git 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 a42c3672..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 @@ -30,10 +30,11 @@ import org.simantics.db.ReadGraph; import org.simantics.db.Session; import org.simantics.db.UndoContext; import org.simantics.db.WriteGraph; -import org.simantics.db.common.request.ReadRequest; +import org.simantics.db.common.request.UniqueRead; import org.simantics.db.common.request.WriteRequest; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.util.Layer0Utils; +import org.simantics.db.procedure.SyncProcedure; import org.simantics.db.service.UndoRedoSupport; import org.simantics.g3d.ontology.G3D; import org.simantics.g3d.scenegraph.RenderListener; @@ -337,14 +338,23 @@ public abstract class AbstractVTKNodeMap implements VT if (graphUpdates) return; if (DEBUG)System.out.println("domainModified"); - session.asyncRequest(new ReadRequest() { - + session.asyncRequest(new UniqueRead() { + @Override + public Object perform(ReadGraph graph) throws DatabaseException { + return new Object(); + } + }, new SyncProcedure() { @Override - public void run(ReadGraph graph) throws DatabaseException { + public void execute(ReadGraph graph, Object result) throws DatabaseException { + // Perform all updates to the model in a single query thread update(graph); + }; + + @Override + public void exception(ReadGraph graph, Throwable throwable) throws DatabaseException { + LOGGER.error("Failed to update pipeline changes" + throwable); } }); - } protected void reset(ReadGraph graph) throws MappingException { @@ -362,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") @@ -375,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 @@ -428,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) { @@ -450,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) {