Allow layer.destroy to be called twice without failing for the vector layer. r=elemoine (closes #1697)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@7941 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -492,12 +492,12 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
* options - {Object}
|
||||
*/
|
||||
removeFeatures: function(features, options) {
|
||||
if(!features || features.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (!(features instanceof Array)) {
|
||||
features = [features];
|
||||
}
|
||||
if (features.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var notify = !options || !options.silent;
|
||||
|
||||
@@ -567,9 +567,11 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
if(all) {
|
||||
features = this.features;
|
||||
}
|
||||
this.removeFeatures(features, options);
|
||||
for (var i = 0; i < features.length; i++) {
|
||||
features[i].destroy();
|
||||
if(features) {
|
||||
this.removeFeatures(features, options);
|
||||
for(var i=features.length-1; i>=0; i--) {
|
||||
features[i].destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user