]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fix a potential race condition in experiment initialization
authorjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 11 Jun 2015 09:44:20 +0000 (09:44 +0000)
committerjkauttio <jkauttio@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 11 Jun 2015 09:44:20 +0000 (09:44 +0000)
refs #5895

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

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

index 08ffd495926f2cff7f28eedd39f77ecaef0b9e5a..7040f9ace1c227d4afa1a8e09adbc87c53c2f7c9 100644 (file)
@@ -87,8 +87,8 @@ public class SysdynExperiments {
             @Override\r
             public void onExperimentActivated(final IExperiment experiment) {\r
 //                MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null));\r
+               run.set(experiment);\r
                 activated.release();\r
-                run.set(experiment);\r
             }\r
             @Override\r
             public void onFailure(Throwable e) {\r
@@ -106,6 +106,8 @@ public class SysdynExperiments {
         }, true);\r
         try {\r
             activated.acquire();\r
+            //System.err.println("foobar");\r
+            //System.err.println(manager.getExperiment(run.get().getIdentifier()));\r
             Throwable t = problem.get();\r
             if (t != null) {\r
                 if (t instanceof ExperimentLoadingFailed) {\r
@@ -124,7 +126,7 @@ public class SysdynExperiments {
     }\r
        \r
     \r
-    public static String activateExperiment(Resource experiment) throws DatabaseException {\r
+    public static String activateExperiment(Resource experiment) {\r
 \r
 //     Resource experiment = Layer0Utils.getPossibleChild(graph, model, name);\r
 //     if( experiment == null) return false;\r
@@ -142,7 +144,7 @@ public class SysdynExperiments {
                \r
        }\r
     \r
-    public static void run(String experimentId) throws DatabaseException {\r
+    public static void run(String experimentId) {\r
 \r
         final IProject project = Simantics.getProject();\r
         if (project == null) return;\r
@@ -156,7 +158,7 @@ public class SysdynExperiments {
         \r
     }\r
     \r
-    public static List<Tuple2> getResult(String experimentId, String variableName) {\r
+    public static List<Tuple2> experimentResult(String experimentId, String variableName) {\r
 \r
                final IProject project = Simantics.getProject();\r
                if (project == null) return null;\r
@@ -171,6 +173,10 @@ public class SysdynExperiments {
                \r
                SysdynDataSet dataset = ((SysdynExperiment)experiment).getCurrentResult().getDataSet(variableName);\r
                \r
+               if (dataset == null) {\r
+                       return null;\r
+               }\r
+               \r
                List<Tuple2> results = new ArrayList<Tuple2>();\r
                \r
                for (int i = 0; i < dataset.times.length; i++) {\r