[OpenLayers-Commits] r12083 - in trunk/openlayers: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Jun 15 03:21:19 EDT 2011


Author: pgiraud
Date: 2011-06-15 00:21:18 -0700 (Wed, 15 Jun 2011)
New Revision: 12083

Modified:
   trunk/openlayers/lib/OpenLayers/Handler/Path.js
   trunk/openlayers/tests/Handler/Path.html
Log:
Persisted features not correctly removed in Handler.Path and freehand mode, p=jorix,me, r=erilem

Modified: trunk/openlayers/lib/OpenLayers/Handler/Path.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Handler/Path.js	2011-06-14 06:46:13 UTC (rev 12082)
+++ trunk/openlayers/lib/OpenLayers/Handler/Path.js	2011-06-15 07:21:18 UTC (rev 12083)
@@ -339,6 +339,9 @@
     up: function (evt) {
         if (this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
             if(this.stoppedDown && this.freehandMode(evt)) {
+                if (this.persist) {
+                    this.destroyPersistedFeature();
+                }
                 this.removePoint();
                 this.finalize();
             } else {

Modified: trunk/openlayers/tests/Handler/Path.html
===================================================================
--- trunk/openlayers/tests/Handler/Path.html	2011-06-14 06:46:13 UTC (rev 12082)
+++ trunk/openlayers/tests/Handler/Path.html	2011-06-15 07:21:18 UTC (rev 12083)
@@ -959,6 +959,48 @@
         map.destroy();
     }
 
+    function test_persist_one_click_freehand(t) {
+        t.plan(3);
+        var map = new OpenLayers.Map("map", {
+            resolutions: [1]
+        });
+        var layer = new OpenLayers.Layer.Vector("foo", {
+            maxExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
+            isBaseLayer: true
+        });
+        map.addLayer(layer);
+        var control = new OpenLayers.Control({});
+        var handler = new OpenLayers.Handler.Path(control, {}, {persist: true});
+        control.handler = handler;
+        map.addControl(control);
+        map.setCenter(new OpenLayers.LonLat(0, 0), 0);
+
+        handler.activate();
+
+        handler.mousemove(
+            {type: "mousemove", xy: new OpenLayers.Pixel(0, 0)});
+        handler.mousedown(
+            {type: "mousedown", xy: new OpenLayers.Pixel(0, 0), shiftKey: true});
+        var feature1 = handler.line;
+        handler.mousemove(
+            {type: "mousemove", xy: new OpenLayers.Pixel(1, 1), shiftKey: true});
+        handler.mouseup(
+            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1), shiftKey: true});
+        t.ok(feature1.layer != null, "a) feature1 not destroyed");
+
+        // one click freehand
+        handler.mousemove(
+            {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
+        handler.mousedown(
+            {type: "mousedown", xy: new OpenLayers.Pixel(2, 2), shiftKey: true});
+        var feature2 = handler.line;
+        handler.mouseup(
+            {type: "mouseup", xy: new OpenLayers.Pixel(2, 2), shiftKey: true});
+        t.ok(feature2.layer != null, "b) feature2 not destroyed");
+        t.ok(feature1.layer == null, "b) feature1 destroyed");
+        
+        map.destroy();
+    }
   </script>
 </head>
 <body>



More information about the Commits mailing list