better cleanup for ZoomBar and PanZoomBar. Fixes a memory leak.
r=crschmidt (closes #1949) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9113 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -54,11 +54,7 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
destroy: function() {
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
while(this.buttons.length) {
|
||||
var btn = this.buttons.shift();
|
||||
btn.map = null;
|
||||
OpenLayers.Event.stopObservingElement(btn);
|
||||
}
|
||||
this.removeButtons();
|
||||
this.buttons = null;
|
||||
this.position = null;
|
||||
},
|
||||
@@ -135,6 +131,28 @@ OpenLayers.Control.PanZoom = OpenLayers.Class(OpenLayers.Control, {
|
||||
return btn;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: _removeButton
|
||||
*
|
||||
* Parameters:
|
||||
* btn - {Object}
|
||||
*/
|
||||
_removeButton: function(btn) {
|
||||
OpenLayers.Event.stopObservingElement(btn);
|
||||
btn.map = null;
|
||||
this.div.removeChild(btn);
|
||||
OpenLayers.Util.removeItem(this.buttons, btn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeButtons
|
||||
*/
|
||||
removeButtons: function() {
|
||||
for(var i=this.buttons.length-1; i>=0; --i) {
|
||||
this._removeButton(this.buttons[i]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: doubleClick
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user