From 19b18a0c3fd0329b4aee51ff5e75403f6beffb6e Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Mon, 2 Jul 2012 21:42:04 +0000 Subject: [PATCH] Bugfix in approximate simulation: property error was causing null ptr. git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@5419 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/simulator/SimulatorEngine.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/prism/src/simulator/SimulatorEngine.java b/prism/src/simulator/SimulatorEngine.java index 5d2e839e..1a86964b 100644 --- a/prism/src/simulator/SimulatorEngine.java +++ b/prism/src/simulator/SimulatorEngine.java @@ -553,6 +553,7 @@ public class SimulatorEngine * The resulting index of the property is returned: this is used for later queries about the property. * Any constants/formulas etc. appearing in the property must have been defined in the current model * or be supplied in the (optional) passed in PropertiesFile. + * In case of error, the property is not added an exception is thrown. */ public int addProperty(Expression prop, PropertiesFile pf) throws PrismException { @@ -567,9 +568,12 @@ public class SimulatorEngine propNew = (Expression) propNew.replaceConstants(pf.getConstantValues()); } propNew = (Expression) propNew.simplify(); - // Create sampler, update lists and return index + // Create sampler + Sampler sampler = Sampler.createSampler(propNew, modulesFile); + // Update lists and return index + // (do this right at the end so that lists only get updated if there are no errors) properties.add(propNew); - propertySamplers.add(Sampler.createSampler(propNew, modulesFile)); + propertySamplers.add(sampler); return properties.size() - 1; }