From: Miro Richard Eklund Date: Tue, 14 Jan 2020 10:50:50 +0000 (+0200) Subject: Ensure unloadFMU is called only if FMU instance (pointer) exists X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=bc0dbe3b8e68fb3373b6b5865b69eccadad4b2fc;hp=5d6e41ca7f0ddc0dd10b6f66fd8442295ec694c2;p=simantics%2Ffmil.git Ensure unloadFMU is called only if FMU instance (pointer) exists Previous assumptions of unloadFMU was that there was a valid C-level pointer to cleanup and pass to the FMU model's cleanup functions. However, if only loadFMU is called prior to unloadFMU, then JVM would crash with an access violation exception. I introduced a boolean for instantiated to keep track of this to ensure we avoid future crashes if unloadFMU is called directly after loadFMU. gitlab #13 Change-Id: Idef742d6805e856617c3c95c0bb751d8a48caa0d --- diff --git a/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java b/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java index 4b1eeac..ec63279 100644 --- a/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java +++ b/org.simantics.fmil.core/src/org/simantics/fmil/core/FMIL.java @@ -184,7 +184,7 @@ public class FMIL { * @throws FMILException */ private int fmuN = 0; - private boolean fmuLoaded = false; + private boolean instantiated = false; public void loadFMUFile(String path) throws FMILException { if (!Files.exists(Paths.get(path))) @@ -229,8 +229,8 @@ public class FMIL { for(int i=0;i