]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Empty FMU would be created and system would crash.
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Jul 2013 12:05:16 +0000 (12:05 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Mon, 15 Jul 2013 12:05:16 +0000 (12:05 +0000)
refs #3552

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

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

index d4b865f410ecd9482c8839e7bad1c41b64e92de0..b2e05e16c461d7b77c53067cfb6f856a983d393d 100644 (file)
@@ -167,6 +167,13 @@ public class SysdynGameExperiment extends SysdynExperiment {
                }\r
        }\r
 \r
+       private boolean isValidFMU(File file) {\r
+               if(!file.exists()) return false;\r
+               if(!file.isFile()) return false;\r
+               if(file.length() == 0) return false;\r
+               return true;\r
+       }\r
+       \r
 \r
        @Override\r
        public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor) throws IOException {\r
@@ -204,7 +211,7 @@ public class SysdynGameExperiment extends SysdynExperiment {
                }\r
                // Build the model and store previous model structure and inits that affect the building\r
                // If there is no exe file OR the model structure has not changed, no need to build\r
-               if (fmu == null && (!simulationLocation.executableFile.isFile() || sysdynModel.isStructureModified())) {\r
+               if (fmu == null && (!isValidFMU(simulationLocation.executableFile) || sysdynModel.isStructureModified())) {\r
                        progressMonitor.subTask("Build model");\r
                        buildModel(simulationLocation, monitor);\r
                        previousModelStructure = modelText;\r