Ticket #1697: destroy2x.2.patch
| File destroy2x.2.patch, 2.1 kB (added by tschaub, 4 months ago) |
|---|
-
tests/Layer/Vector.html
old new 238 238 } 239 239 240 240 function test_Layer_Vector_destroy (t) { 241 t.plan( 4);241 t.plan(5); 242 242 243 243 var options = {protocol: new OpenLayers.Protocol(), 244 244 strategies: [new OpenLayers.Strategy(), new OpenLayers.Strategy()]} … … 252 252 253 253 t.eq(layer.protocol, null, "layer.protocol is null after destroy"); 254 254 t.eq(layer.strategies, null, "layer.strategies is null after destroy"); 255 256 // test that we can call layer.destroy a second time without trouble 257 try { 258 layer.destroy(); 259 layer.destroy(); 260 t.ok(true, "layer.destroy called twice without any issues"); 261 } catch(err) { 262 t.fail("calling layer.destroy twice triggers exception: " + err + " in " + err.fileName + " line " + err.lineNumber); 263 } 264 255 265 } 256 266 257 267 function test_Layer_Vector_externalGraphic(t) { -
lib/OpenLayers/Layer/Vector.js
old new 492 492 * options - {Object} 493 493 */ 494 494 removeFeatures: function(features, options) { 495 if(!features || features.length === 0) { 496 return; 497 } 495 498 if (!(features instanceof Array)) { 496 499 features = [features]; 497 500 } 498 if (features.length <= 0) {499 return;500 }501 501 502 502 var notify = !options || !options.silent; 503 503 … … 567 567 if(all) { 568 568 features = this.features; 569 569 } 570 this.removeFeatures(features, options); 571 for (var i = 0; i < features.length; i++) { 572 features[i].destroy(); 570 if(features) { 571 this.removeFeatures(features, options); 572 for (var i = 0; i < features.length; i++) { 573 features[i].destroy(); 574 } 573 575 } 574 576 }, 575 577
