OpenLayers OpenLayers

Ticket #964: wfsAbort.patch

File wfsAbort.patch, 3.0 kB (added by tschaub, 1 year ago)

abort wfs request on tile destroy

  • tests/Tile/test_WFS.html

    old new  
    4242    } 
    4343     
    4444    function test_99_Tile_WFS_destroy(t) { 
    45         t.plan( 6 ); 
     45        t.plan(8); 
    4646 
    4747        var layer = {}; // bogus layer 
    4848        var position = new OpenLayers.Pixel(10,20); 
     
    5656        }; 
    5757 
    5858  
     59        var _gAbort = false;  
     60        tile.request = {  
     61            transport: {  
     62                abort: function() {  
     63                    _gAbort = true;  
     64                }  
     65            }  
     66        }  
     67 
     68         
    5969        tile.destroy(); 
    6070 
    6171        t.ok(tile.layer == null, "tile.layer set to null"); 
    6272        t.ok(tile.bounds == null, "tile.bounds set to null"); 
    6373        t.ok(tile.size == null, "tile.size set to null"); 
    6474        t.ok(tile.position == null, "tile.position set to null"); 
     75        t.ok(_gAbort, "request transport is aborted"); 
    6576         
    6677        t.ok(tile.events == null, "tile.events set to null"); 
     78         
     79        tile.requestSuccess({'requestText': '<xml><foo /></xml>'}); 
     80        t.ok(true, "Didn't fail after calling requestSuccess on destroyed tile."); 
    6781    } 
    6882 
    6983  </script> 
  • lib/OpenLayers/Tile/WFS.js

    old new  
    2828     */ 
    2929    url: null, 
    3030     
     31    /**  
     32     * Property: request  
     33     * {OpenLayers.Ajax.Request}  
     34     */  
     35    request: null,      
     36     
    3137    /** TBD 3.0 - reorder the parameters to the init function to put URL  
    3238     *             as last, so we can continue to call tile.initialize()  
    3339     *             without changing the arguments.  
     
    5763        this.destroyAllFeatures(); 
    5864        this.features = null; 
    5965        this.url = null; 
     66        if(this.request) { 
     67            this.request.transport.abort(); 
     68        } 
    6069    }, 
    6170 
    6271    /**  
     
    97106    * failure - {function} 
    98107    */ 
    99108    loadFeaturesForRegion:function(success, failure) { 
    100         OpenLayers.loadURL(this.url, null, this, success); 
     109        this.request = OpenLayers.loadURL(this.url, null, this, success); 
    101110    }, 
    102111     
    103112    /** 
  • lib/OpenLayers/Ajax.js

    old new  
    6464                           : OpenLayers.nullHandler; 
    6565 
    6666    // from prototype.js 
    67     new OpenLayers.Ajax.Request(uri,  
    68                      {   method: 'get',  
    69                          parameters: params, 
    70                          onComplete: success,  
    71                          onFailure: failure 
    72                       } 
    73                      ); 
     67    return new OpenLayers.Ajax.Request( 
     68        uri,  
     69        { 
     70            method: 'get',  
     71            parameters: params, 
     72            onComplete: success,  
     73            onFailure: failure 
     74        } 
     75    ); 
    7476}; 
    7577 
    7678/**