From 579f8512543a88945e94ce619a4a20c307e67f4f Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 25 Nov 2019 09:14:04 +0200 Subject: [PATCH] SCLFunctions.syncWrite does not check if graph is WriteGraph gitlab #425 Change-Id: Icb771e425c170e00385b943a6a6dde2cf62e2d9b --- .../src/org/simantics/scl/db/SCLFunctions.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 09022d543..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 @@ -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 -- 2.47.1