X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.db%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fdb%2FSCLFunctions.java;h=9f242b28c8efade8dc8d606d4c6409bd94b86a69;hp=d8f83e05f5b2f231bc5dcd14bf27bf93ff85ffdc;hb=7b05bde892ab8a6203d5cda230b34e2e5cd3e5bb;hpb=1ae2c52a087a20a7fc9c0288b7e2398b4429e20e diff --git a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java index d8f83e05f..9f242b28c 100644 --- a/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java +++ b/bundles/org.simantics.scl.db/src/org/simantics/scl/db/SCLFunctions.java @@ -123,7 +123,7 @@ public class SCLFunctions { } private static T evaluate(RuntimeModule rm, String function, Object ... args) throws ValueNotFound { - return evaluate(resolveFunction(rm, function)); + return evaluate(resolveFunction(rm, function), args); } public static T evaluate(String module, String function, Object ... args) throws ValueNotFound { @@ -151,7 +151,7 @@ public class SCLFunctions { } } - public static T evaluateGraph(String module, String function, Object graph, Object ... args) throws DatabaseException { + public static T evaluateGraph(String module, String function, ReadGraph graph, Object ... args) throws DatabaseException { final SCLContext context = SCLContext.getCurrent(); SCLContext.push(context); Object oldGraph = context.put(GRAPH, graph); @@ -163,7 +163,7 @@ public class SCLFunctions { } } - public static void runWithGraph(Object graph, Runnable r) { + public static void runWithGraph(ReadGraph graph, Runnable r) { final SCLContext context = SCLContext.getCurrent(); SCLContext.push(context); Object oldGraph = context.put(GRAPH, graph); @@ -254,9 +254,14 @@ public class SCLFunctions { public static 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() { @Override