X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.acorn%2Fsrc%2Forg%2Fsimantics%2Facorn%2FGraphClientImpl2.java;h=774b605541371766333fa19957e57171bc40fdab;hp=2796e3e02e32ce514a7d7226c4e029708bcf24b0;hb=80907a9c5480a15ee32db2f7e7acec3dd1b6d9d5;hpb=ad811ef47b6daa8aaa5b1011f2438bd55c29ae2a diff --git a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java index 2796e3e02..774b60554 100644 --- a/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java +++ b/bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java @@ -140,7 +140,8 @@ public class GraphClientImpl2 implements Database.Session { } public void makeSnapshot(boolean force) throws IOException { - clusters.makeSnapshot(locator, force); + if (safeToMakeSnapshot) + clusters.makeSnapshot(locator, force); } public T clone(ClusterUID uid, ClusterCreator creator) throws DatabaseException { @@ -166,6 +167,8 @@ public class GraphClientImpl2 implements Database.Session { private boolean closed = false; private boolean isClosing = false; + // Add check to make sure if it safe to make snapshot (used with cancel which is not yet supported and may cause corrupted head.state writing) + private boolean safeToMakeSnapshot = true; @Override public void close() throws ProCoreException { @@ -173,7 +176,7 @@ public class GraphClientImpl2 implements Database.Session { if(!closed && !isClosing) { isClosing = true; try { - makeSnapshot(true); + makeSnapshot(true); mainProgram.close(); clusters.shutdown(); @@ -228,15 +231,17 @@ public class GraphClientImpl2 implements Database.Session { public long cancelCommit(long transactionId, long changeSetId, byte[] metadata, OnChangeSetUpdate onChangeSetUpdate) throws ProCoreException { - System.err.println("GraphClientImpl2.cancelCommit() called!! this is experimental and might cause havoc!"); - try { - undo(new long[] {changeSetId}, onChangeSetUpdate); - } catch (SDBException e) { - e.printStackTrace(); - throw new ProCoreException(e); - } - clusters.state.headChangeSetId++; - return clusters.state.headChangeSetId; + safeToMakeSnapshot = false; + throw new UnsupportedOperationException("org.simantics.acorn.GraphClientImpl2.cancelCommit() is not supported operation! Closing down to prevent further havoc"); +// System.err.println("GraphClientImpl2.cancelCommit() called!! this is experimental and might cause havoc!"); +// try { +// undo(new long[] {changeSetId}, onChangeSetUpdate); +// } catch (SDBException e) { +// e.printStackTrace(); +// throw new ProCoreException(e); +// } +// clusters.state.headChangeSetId++; +// return clusters.state.headChangeSetId; } @Override