Create a new machine when a MachineContext is used and has a definition.
authorChristian Femers <femers@in.tum.de>
Mon, 23 Sep 2019 14:53:05 +0000 (16:53 +0200)
committerChristian Femers <femers@in.tum.de>
Mon, 23 Sep 2019 14:53:05 +0000 (16:53 +0200)
This might be refined in future to a somewhat more lazy creation, but
for now it fixes the bug that a machine context has no machine at the
start, and it is not clear, when else it should be created.

plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MachineContext.java

index b170848..c65a95e 100644 (file)
@@ -112,6 +112,7 @@ public class MachineContext
        final void updateDefinition()
        {
                machineDefinition = machineId.map(MachineRegistry::getMachine);
+               machineDefinition.ifPresent(md -> setActiveMachine(md.createNew()));
        }
 
        private void preferenceListener(PropertyChangeEvent changeEvent)