From 51d2d60cc88c4ef5418aa619a09067b37b344688 Mon Sep 17 00:00:00 2001 From: villberg Date: Mon, 15 Jul 2013 12:05:16 +0000 Subject: [PATCH] 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 --- .../simantics/sysdyn/manager/SysdynGameExperiment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- 2.47.1