Reordered the disposal of the old resources, because of errors
authorChristian Femers <femers@in.tum.de>
Thu, 26 Sep 2019 04:53:59 +0000 (06:53 +0200)
committerChristian Femers <femers@in.tum.de>
Thu, 26 Sep 2019 04:53:59 +0000 (06:53 +0200)
Apparently this was able to lead to "widget disposed" exceptions, and
for some reason the old canvas sill stays at it's place, causing two
canvases side by side.

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())