diff --git a/lib/OpenLayers/Control/ModifyFeature.js b/lib/OpenLayers/Control/ModifyFeature.js index 8b381420f6..d5823c08aa 100644 --- a/lib/OpenLayers/Control/ModifyFeature.js +++ b/lib/OpenLayers/Control/ModifyFeature.js @@ -428,6 +428,16 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, { * Method: resetVertices */ resetVertices: function() { + // if coming from a drag complete we're about to destroy the vertex + // that was just dragged. For that reason, the drag feature control + // will never detect a mouse-out on that vertex, meaning that the drag + // handler won't be deactivated. This can cause errors because the drag + // feature control still has a feature to drag but that feature is + // destroyed. To prevent this, we call outFeature on the drag feature + // control if the control actually has a feature to drag. + if(this.dragControl.feature) { + this.dragControl.outFeature(this.dragControl.feature); + } if(this.vertices.length > 0) { this.layer.removeFeatures(this.vertices); this.vertices = []; diff --git a/tests/Control/test_ModifyFeature.html b/tests/Control/test_ModifyFeature.html index 46da2ecf47..dc2a788425 100644 --- a/tests/Control/test_ModifyFeature.html +++ b/tests/Control/test_ModifyFeature.html @@ -249,7 +249,7 @@ } function test_ModifyFeature_resetVertices(t) { - t.plan(17); + t.plan(18); var layer = new OpenLayers.Layer.Vector(); var control = new OpenLayers.Control.ModifyFeature(layer); var point = new OpenLayers.Geometry.Point(5,6); @@ -299,6 +299,21 @@ t.ok(control.radiusHandle != null, "Radius handle is set"); t.eq(control.vertices.length, 3, "Correct vertices length with polygon (RESHAPE | RESIZE)"); t.eq(control.virtualVertices.length, 3, "Correct virtual vertices length (RESHAPE | RESIZE)"); + + control.dragControl.feature = new OpenLayers.Feature.Vector(polygon); + control.dragControl.map = {}; + control.dragControl.map.div = {}; + control.dragControl.map.div.style = {}; + control.dragControl.map.div.cursor = "foo"; + control.dragControl.dragHandler.deactivate = function() { + this.active = false; + } + control.resetVertices(); + t.ok(!control.dragControl.dragHandler.active, "resetVertices deactivates drag handler"); + control.dragControl.map = null; + + control.destroy(); + layer.destroy(); } function test_ModifyFeature_onDrag(t) {