diff --git a/gama.core/src/gama/core/kernel/experiment/ExperimentAgent.java b/gama.core/src/gama/core/kernel/experiment/ExperimentAgent.java index 3f3821e793..8218fe1ce3 100644 --- a/gama.core/src/gama/core/kernel/experiment/ExperimentAgent.java +++ b/gama.core/src/gama/core/kernel/experiment/ExperimentAgent.java @@ -358,7 +358,7 @@ public void dispose() { if (dying || dead) return; dying = true; getSpecies().getArchitecture().abort(ownScope); - closeSimulations(true); + closeSimulations(!getSpecies().isReloading()); GAMA.releaseScope(ownScope); super.dispose(); } diff --git a/gama.core/src/gama/core/kernel/experiment/ExperimentPlan.java b/gama.core/src/gama/core/kernel/experiment/ExperimentPlan.java index f04e541809..771ccd155b 100644 --- a/gama.core/src/gama/core/kernel/experiment/ExperimentPlan.java +++ b/gama.core/src/gama/core/kernel/experiment/ExperimentPlan.java @@ -771,12 +771,26 @@ public synchronized void open() { open(seed); } + // Horrible workaround for #334 + // ---------------------------------------------------------------------------------- + private volatile boolean reloading; + @Override public void reload() { - agent.dispose(); + try { + + reloading = true; + agent.dispose(); + } finally { + reloading = false; + } open(); } + @Override + public boolean isReloading() { return reloading; } + // ---------------------------------------------------------------------------------- + @Override public boolean hasParametersOrUserCommands() { return !displayables.isEmpty() || GamaPreferences.Runtime.CORE_MONITOR_PARAMETERS.getValue() diff --git a/gama.core/src/gama/core/kernel/experiment/IExperimentPlan.java b/gama.core/src/gama/core/kernel/experiment/IExperimentPlan.java index 4bc013feff..70b3321462 100644 --- a/gama.core/src/gama/core/kernel/experiment/IExperimentPlan.java +++ b/gama.core/src/gama/core/kernel/experiment/IExperimentPlan.java @@ -342,4 +342,11 @@ default void setStopCondition(final String cond) { * @date 15 oct. 2023 */ void setParameterValues(IList params); + + /** + * Whether the current experiment is reloading or not (see #344) + * + * @return + */ + boolean isReloading(); } \ No newline at end of file diff --git a/gama.core/src/gama/core/outputs/AbstractOutputManager.java b/gama.core/src/gama/core/outputs/AbstractOutputManager.java index f050d6ce5d..4e9cda5bb1 100644 --- a/gama.core/src/gama/core/outputs/AbstractOutputManager.java +++ b/gama.core/src/gama/core/outputs/AbstractOutputManager.java @@ -62,8 +62,8 @@ public abstract class AbstractOutputManager extends Symbol implements IOutputMan LayoutStatement layout; /** The outputs. */ - protected final Map outputs = GamaMapFactory.create(); - // GamaMapFactory.synchronizedOrderedMap(); + protected final Map outputs = // GamaMapFactory.create(); + GamaMapFactory.synchronizedOrderedMap(); // protected final IList monitors = GamaListFactory.create();