SVE now supports context changes better (untested)
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 25 Sep 2019 10:42:07 +0000 (12:42 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 25 Sep 2019 10:42:07 +0000 (12:42 +0200)
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java

index 4dd346b..12865a6 100644 (file)
@@ -54,6 +54,7 @@ public class SimulationViewEditor extends EditorPart
        private Label noMachineLabel;
 
        private MemoryCellModifiedListener currentRegisteredCellListener;
+       private LogicObserver currentClockObserver;
 
        @Override
        public void createPartControl(Composite parent)
@@ -88,7 +89,10 @@ public class SimulationViewEditor extends EditorPart
                        simSpeedSlider.setEnabled(true);
 
                        if (machine != null)
+                       {
                                machine.getMicroInstructionMemory().deregisterCellModifiedListener(currentRegisteredCellListener);
+                               machine.getClock().deregisterObserver(currentClockObserver);
+                       }
 
                        machine = machineOptional.get();
                        canvas = new LogicUICanvas(parent, SWT.NONE, machine.getModel());
@@ -129,7 +133,7 @@ public class SimulationViewEditor extends EditorPart
 
                sbseButton = new Button(c, SWT.CHECK);
                pauseButton = new Button(c, SWT.TOGGLE);
-               LogicObserver clockObserver = o ->
+               currentClockObserver = o ->
                {
                        if (((CoreClock) o).isOn())
                        {
@@ -149,9 +153,9 @@ public class SimulationViewEditor extends EditorPart
                {
                        CoreClock cl = machine.getClock();
                        if (sbseButton.getSelection())
-                               cl.registerObserver(clockObserver);
+                               cl.registerObserver(currentClockObserver);
                        else
-                               cl.deregisterObserver(clockObserver);
+                               cl.deregisterObserver(currentClockObserver);
                });
                sbseButton.setSelection(false);