From: villberg Date: Mon, 15 Jul 2013 12:05:16 +0000 (+0000) Subject: Empty FMU would be created and system would crash. X-Git-Tag: 1.8.1~259 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=51d2d60cc88c4ef5418aa619a09067b37b344688;p=simantics%2Fsysdyn.git Empty FMU would be created and system would crash. refs #3552 git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27709 ac1ea38d-2e2b-0410-8846-a27921b304fc --- diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java index d4b865f4..b2e05e16 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java @@ -167,6 +167,13 @@ public class SysdynGameExperiment extends SysdynExperiment { } } + private boolean isValidFMU(File file) { + if(!file.exists()) return false; + if(!file.isFile()) return false; + if(file.length() == 0) return false; + return true; + } + @Override public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException { @@ -204,7 +211,7 @@ public class SysdynGameExperiment extends SysdynExperiment { } // Build the model and store previous model structure and inits that affect the building // If there is no exe file OR the model structure has not changed, no need to build - if (fmu == null && (!simulationLocation.executableFile.isFile() || sysdynModel.isStructureModified())) { + if (fmu == null && (!isValidFMU(simulationLocation.executableFile) || sysdynModel.isStructureModified())) { progressMonitor.subTask("Build model"); buildModel(simulationLocation, monitor); previousModelStructure = modelText;