Subclasses of markers layer should destroy, then clear their list of markers.

Thanks crschmidt for the review. (closes #1123)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5465 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2007-12-17 09:03:01 +00:00
parent 772b6452ce
commit a1522246a6
2 changed files with 12 additions and 2 deletions

View File

@@ -75,9 +75,14 @@ OpenLayers.Layer.GeoRSS = OpenLayers.Class(OpenLayers.Layer.Markers, {
* Method: destroy
*/
destroy: function() {
// Warning: Layer.Markers.destroy() must be called prior to calling
// clearFeatures() here, otherwise we leak memory. Indeed, if
// Layer.Markers.destroy() is called after clearFeatures(), it won't be
// able to remove the marker image elements from the layer's div since
// the markers will have been destroyed by clearFeatures().
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
this.clearFeatures();
this.features = null;
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
},
/**

View File

@@ -86,9 +86,14 @@ OpenLayers.Layer.Text = OpenLayers.Class(OpenLayers.Layer.Markers, {
* APIMethod: destroy
*/
destroy: function() {
// Warning: Layer.Markers.destroy() must be called prior to calling
// clearFeatures() here, otherwise we leak memory. Indeed, if
// Layer.Markers.destroy() is called after clearFeatures(), it won't be
// able to remove the marker image elements from the layer's div since
// the markers will have been destroyed by clearFeatures().
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
this.clearFeatures();
this.features = null;
OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
},