From: jkauttio Date: Thu, 11 Jun 2015 09:44:20 +0000 (+0000) Subject: Fix a potential race condition in experiment initialization X-Git-Tag: v1.29.0~66 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1a66ac5c0bd6654ea060f8f223f32a0d42788d40;p=simantics%2Fsysdyn.git Fix a potential race condition in experiment initialization refs #5895 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@31403 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java index 08ffd495..7040f9ac 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java @@ -87,8 +87,8 @@ public class SysdynExperiments { @Override public void onExperimentActivated(final IExperiment experiment) { // MessageService.defaultLog(new org.eclipse.core.runtime.Status(IStatus.INFO, "org.simantics.simulation.ui", 0, "Activated experiment " + experiment.getIdentifier() , null)); + run.set(experiment); activated.release(); - run.set(experiment); } @Override public void onFailure(Throwable e) { @@ -106,6 +106,8 @@ public class SysdynExperiments { }, true); try { activated.acquire(); + //System.err.println("foobar"); + //System.err.println(manager.getExperiment(run.get().getIdentifier())); Throwable t = problem.get(); if (t != null) { if (t instanceof ExperimentLoadingFailed) { @@ -124,7 +126,7 @@ public class SysdynExperiments { } - public static String activateExperiment(Resource experiment) throws DatabaseException { + public static String activateExperiment(Resource experiment) { // Resource experiment = Layer0Utils.getPossibleChild(graph, model, name); // if( experiment == null) return false; @@ -142,7 +144,7 @@ public class SysdynExperiments { } - public static void run(String experimentId) throws DatabaseException { + public static void run(String experimentId) { final IProject project = Simantics.getProject(); if (project == null) return; @@ -156,7 +158,7 @@ public class SysdynExperiments { } - public static List getResult(String experimentId, String variableName) { + public static List experimentResult(String experimentId, String variableName) { final IProject project = Simantics.getProject(); if (project == null) return null; @@ -171,6 +173,10 @@ public class SysdynExperiments { SysdynDataSet dataset = ((SysdynExperiment)experiment).getCurrentResult().getDataSet(variableName); + if (dataset == null) { + return null; + } + List results = new ArrayList(); for (int i = 0; i < dataset.times.length; i++) {