2170_tileEvents.html: fixed memory leak with tile events. p=rcoup, r=me (see #2170)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9760 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2009-10-24 09:27:14 +00:00
parent ee737577f7
commit c67d1f5952
2 changed files with 12 additions and 3 deletions

View File

@@ -110,12 +110,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
if (this.imgDiv != null) {
if (this.layerAlphaHack) {
// unregister the "load" handler
OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0].id);
OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0]);
}
// unregister the "load" and "error" handlers. Only the "error" handler if
// this.layerAlphaHack is true.
OpenLayers.Event.stopObservingElement(this.imgDiv.id);
OpenLayers.Event.stopObservingElement(this.imgDiv);
if (this.imgDiv.parentNode == this.frame) {
this.frame.removeChild(this.imgDiv);

View File

@@ -595,7 +595,7 @@
function test_Layer_Grid_destroy (t) {
t.plan( 5 );
t.plan( 7 );
var map = new OpenLayers.Map('map');
layer = new OpenLayers.Layer.Grid(name, url, params);
@@ -620,6 +620,15 @@
t.eq( tile.imgDiv, null, "Tile destroyed" );
t.ok( layer.grid == null, "tiles appropriately destroyed")
// destroy after remove from map
layer = new OpenLayers.Layer.WMS(name, url, params);
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0,0), 10);
map.removeLayer(layer);
layer.destroy();
t.eq( layer.grid, null, "layer.grid is null after destroy" );
t.eq( layer.tileSize, null, "layer.tileSize is null after destroy" );
}