]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.acorn/src/org/simantics/acorn/GraphClientImpl2.java
Some Acorn improvements
[simantics/platform.git] / bundles / org.simantics.acorn / src / org / simantics / acorn / GraphClientImpl2.java
index 2796e3e02e32ce514a7d7226c4e029708bcf24b0..774b605541371766333fa19957e57171bc40fdab 100644 (file)
@@ -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> 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