Only use previousState in DragBackground; fixes memory leak
authorRichard Fairhurst <richard@systemeD.net>
Sat, 12 May 2012 10:10:33 +0000 (11:10 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 12 May 2012 10:10:33 +0000 (11:10 +0100)
net/systemeD/potlatch2/EditController.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DragBackground.as

index 19361b9..91a8ce5 100644 (file)
@@ -175,7 +175,6 @@ package net.systemeD.potlatch2 {
             if ( state != null )
                 state.exitState(newState);
             newState.setController(this);
-            newState.setPreviousState(state);
             state = newState;
             state.enterState();
         }
index 3aea911..92615e5 100644 (file)
@@ -25,7 +25,6 @@ package net.systemeD.potlatch2.controller {
 
         protected var controller:EditController;
                public var layer:MapPaint;
-        protected var previousState:ControllerState;
 
                protected var _selection:Array=[];
 
@@ -36,11 +35,6 @@ package net.systemeD.potlatch2.controller {
             if (!layer) layer=controller.map.editableLayer;
         }
 
-        public function setPreviousState(previousState:ControllerState):void {
-            if ( this.previousState == null )
-                this.previousState = previousState;
-        }
-
                public function isSelectionState():Boolean {
                        return true;
                }
@@ -146,7 +140,7 @@ package net.systemeD.potlatch2.controller {
                                        return new DragWayNode(selectedWay,  getNodeIndex(selectedWay,entity as Node),  event, false);
                                } else if ( controller.spaceHeld ) {
                                        // drag the background imagery to compensate for poor alignment
-                                       return new DragBackground(event);
+                                       return new DragBackground(event, this);
                                } else if (entity && selection.indexOf(entity)>-1) {
                                        return new DragSelection(selection, event);
                                } else if (entity) {
index 7f46b98..f33897e 100644 (file)
@@ -10,11 +10,13 @@ package net.systemeD.potlatch2.controller {
 
         private var downX:Number;
         private var downY:Number;
+        protected var previousState:ControllerState;
         
         /** Start the drag by recording the location of the mouse. */
-        public function DragBackground(event:MouseEvent) {
+        public function DragBackground(event:MouseEvent, previousState:ControllerState) {
             downX = event.localX;
             downY = event.localY;
+            this.previousState = previousState;
         }
  
        /** Respond to dragging and end drag. */