Reordered the disposal of the old resources, because of errors
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / editors / SimulationViewEditor.java
index 2dcbaff..0420334 100644 (file)
@@ -85,6 +85,13 @@ public class SimulationViewEditor extends EditorPart
                double offX;
                double offY;
                double zoom;
+               if (exec != null)
+                       exec.stopLiveExecution();
+               if (machine != null)
+               {
+                       machine.getMicroInstructionMemory().deregisterCellModifiedListener(currentRegisteredCellListener);
+                       machine.getClock().deregisterObserver(currentClockObserver);
+               }
                if (canvas != null)
                {
                        offX = canvas.getOffX();
@@ -97,14 +104,6 @@ public class SimulationViewEditor extends EditorPart
                        offY = 0;
                        zoom = -1;
                }
-               if (exec != null)
-                       exec.stopLiveExecution();
-
-               if (machine != null)
-               {
-                       machine.getMicroInstructionMemory().deregisterCellModifiedListener(currentRegisteredCellListener);
-                       machine.getClock().deregisterObserver(currentClockObserver);
-               }
 
                Optional<Machine> machineOptional;
                if (context != null && (machineOptional = context.getActiveMachine()).isPresent())