]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java
SCLFunctions.syncWrite does not check if graph is WriteGraph
[simantics/platform.git] / bundles / org.simantics.scl.db / src / org / simantics / scl / db / SCLFunctions.java
index 09022d543c1aba3e9101028c88ed939b72759963..9f242b28c8efade8dc8d606d4c6409bd94b86a69 100644 (file)
@@ -254,9 +254,14 @@ public class SCLFunctions {
     public static <T> T syncWrite(final Function f, final Object ... args) throws DatabaseException {
         final SCLContext context = SCLContext.getCurrent();
         Object graph = context.get(GRAPH);
-        if (graph != null) {
+        if (graph != null && graph instanceof WriteGraph) {
             return (T)f.apply(Tuple0.INSTANCE);
         } else {
+            if (graph != null) {
+                LOGGER.error(
+                        "SCLContext {} for current thread {} contains an existing graph object but it is not WriteGraph - Somewhere is a function that forgets to remove the graph from the context!!",
+                        context, Thread.currentThread());
+            }
             final SCLReportingHandler printer = (SCLReportingHandler)SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
             return Simantics.getSession().syncRequest(new WriteResultRequest<T>() {
                 @Override