Prevent single-node ways from being created by undo.
[potlatch2.git] / net / systemeD / halcyon / connection / actions / DeleteWayAction.as
index 00725ff..f2fd1bc 100644 (file)
@@ -26,14 +26,22 @@ package net.systemeD.halcyon.connection.actions {
                        oldNodeList = nodeList.slice();
                        while (nodeList.length > 0) {
                                node=nodeList.pop();
-                               way.dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_REMOVED, node, way, 0));
                                node.removeParent(way);
-                               if (!node.hasParents) { node.remove(effects.push); }
+                               way.dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_REMOVED, node, way, 0));
+                if (!node.hasParents && !node.hasInterestingTags()) { //need to trigger redraw of new POIs?
+                  node.remove(effects.push);
+                }
                        }
                        effects.doAction();
                        setDeleted(true);
-                       markDirty();
-            way.dispatchEvent(new EntityEvent(Connection.WAY_DELETED, way));
+            
+            // see note in DeleteNodeAction
+            if (way.id < 0) {
+              markClean();
+            } else {
+              markDirty();
+            }
+                       way.dispatchEvent(new EntityEvent(Connection.WAY_DELETED, way));        // delete WayUI
                        way.resume();
 
             return SUCCESS;
@@ -43,14 +51,19 @@ package net.systemeD.halcyon.connection.actions {
             var way:Way = entity as Way;
                        way.suspend();
             setDeleted(false);
-            markClean();
-            way.dispatchEvent(new EntityEvent(Connection.NEW_WAY, way));
-            effects.undoAction();
+            if (way.id < 0) {
+              markDirty();
+            } else {
+              markClean();
+            }
+            entity.connection.dispatchEvent(new EntityEvent(Connection.NEW_WAY, way));
+            if (effects) effects.undoAction();
             for each(var node:Node in oldNodeList) {
                 nodeList.push(node);
+               node.addParent(way);
                 way.dispatchEvent(new WayNodeEvent(Connection.WAY_NODE_ADDED, node, way, 0));
             }
-            way.resume();
+                       way.resume();
             return SUCCESS;
         }
     }