OpenLayers OpenLayers

Changeset 5974

Show
Ignore:
Timestamp:
02/03/08 12:10:03 (1 year ago)
Author:
elemoine
Message:

The modify feature control destroys the vertex that was dragged in the drag
complete callback. Thus, the drag feature control won't detect a mouse-out on
that vertex and won't deactivate its drag handler. This causes errors because
the drag feature control has a feature to drag but that feature is destroyed
(feature.geometry is null). To prevent this, we make resetVertices explicitely
call outFeature on the drag feature control if the control has a feature to
drag. tschaub did most of the investigation on the problem. r=tschaub,me
(closes #1235)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control/ModifyFeature.js

    r5897 r5974  
    429429     */ 
    430430    resetVertices: function() { 
     431        // if coming from a drag complete we're about to destroy the vertex 
     432        // that was just dragged. For that reason, the drag feature control 
     433        // will never detect a mouse-out on that vertex, meaning that the drag 
     434        // handler won't be deactivated. This can cause errors because the drag 
     435        // feature control still has a feature to drag but that feature is 
     436        // destroyed. To prevent this, we call outFeature on the drag feature 
     437        // control if the control actually has a feature to drag. 
     438        if(this.dragControl.feature) { 
     439            this.dragControl.outFeature(this.dragControl.feature); 
     440        } 
    431441        if(this.vertices.length > 0) { 
    432442            this.layer.removeFeatures(this.vertices); 
  • trunk/openlayers/tests/Control/test_ModifyFeature.html

    r5623 r5974  
    250250 
    251251    function test_ModifyFeature_resetVertices(t) { 
    252         t.plan(17); 
     252        t.plan(18); 
    253253        var layer = new OpenLayers.Layer.Vector(); 
    254254        var control = new OpenLayers.Control.ModifyFeature(layer); 
     
    300300        t.eq(control.vertices.length, 3, "Correct vertices length with polygon (RESHAPE | RESIZE)"); 
    301301        t.eq(control.virtualVertices.length, 3, "Correct virtual vertices length (RESHAPE | RESIZE)"); 
     302         
     303        control.dragControl.feature = new OpenLayers.Feature.Vector(polygon); 
     304        control.dragControl.map = {}; 
     305        control.dragControl.map.div = {}; 
     306        control.dragControl.map.div.style = {}; 
     307        control.dragControl.map.div.cursor = "foo"; 
     308        control.dragControl.dragHandler.deactivate = function() { 
     309            this.active = false; 
     310        } 
     311        control.resetVertices(); 
     312        t.ok(!control.dragControl.dragHandler.active, "resetVertices deactivates drag handler"); 
     313        control.dragControl.map = null; 
     314         
     315        control.destroy(); 
     316        layer.destroy(); 
    302317    }     
    303318