]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fix a resource name read after the resource is removed
authorjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 13 Jan 2016 13:46:51 +0000 (13:46 +0000)
committerjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 13 Jan 2016 13:46:51 +0000 (13:46 +0000)
refs #6254

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@32258 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java

index aa9744ee967d990f429f5add3e169ba63d3593cc..94c1d5f53aa2ccaac6132f2d0b55320563d97e8a 100644 (file)
@@ -402,13 +402,17 @@ public class SysdynExperiments {
     \r
     public static void deleteIC(WriteGraph graph, Variable input, String name) throws DatabaseException {\r
         graph.markUndoPoint();\r
-       Resource model = Variables.getModel(graph, input);\r
-       Resource child = Layer0Utils.getPossibleChild(graph, model, name);\r
-       SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
-\r
-       if((child != null) && graph.isInstanceOf(child, SYSDYN.InitialCondition))\r
-               RemoverUtil.remove(graph, child);\r
-       Layer0Utils.addCommentMetadata(graph, "Deleted Initial Condition " + graph.getRelatedValue2(child, Layer0.getInstance(graph).HasName, Bindings.STRING));\r
+        Resource model = Variables.getModel(graph, input);\r
+        Resource child = Layer0Utils.getPossibleChild(graph, model, name);\r
+        Layer0 L0 = Layer0.getInstance(graph);\r
+        SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
+\r
+        if((child != null) && graph.isInstanceOf(child, SYSDYN.InitialCondition)) {\r
+            // is it really necessary to fetch the name from the graph and not just use the provided name?\r
+            String actualName = graph.getRelatedValue2(child, L0.HasName, Bindings.STRING);\r
+            RemoverUtil.remove(graph, child);\r
+            Layer0Utils.addCommentMetadata(graph, "Deleted Initial Condition " + actualName);\r
+        }\r
     }\r
     \r
 }\r