]> 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 2fd74b21e3e1c25e7b7b520ba24f559ff0749a06..9f242b28c8efade8dc8d606d4c6409bd94b86a69 100644 (file)
@@ -123,7 +123,7 @@ public class SCLFunctions {
     }
 
     private static <T> T evaluate(RuntimeModule rm, String function, Object ... args) throws ValueNotFound {
-        return evaluate(resolveFunction(rm, function));
+        return evaluate(resolveFunction(rm, function), args);
     }
 
     public static <T> T evaluate(String module, String function, Object ... args) throws ValueNotFound {
@@ -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