Fix for map destroy doesn't clean up all listeners r=tschaub (Closes #1301)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6108 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -373,8 +373,10 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
// Else updateSize on catching the window's resize
|
// Else updateSize on catching the window's resize
|
||||||
// Note that this is ok, as updateSize() does nothing if the
|
// Note that this is ok, as updateSize() does nothing if the
|
||||||
// map's size has not actually changed.
|
// map's size has not actually changed.
|
||||||
|
this.updateSizeDestroy = OpenLayers.Function.bind(this.updateSize,
|
||||||
|
this);
|
||||||
OpenLayers.Event.observe(window, 'resize',
|
OpenLayers.Event.observe(window, 'resize',
|
||||||
OpenLayers.Function.bind(this.updateSize, this));
|
this.updateSizeDestroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only append link stylesheet if the theme property is set
|
// only append link stylesheet if the theme property is set
|
||||||
@@ -435,6 +437,14 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
unloadDestroy: null,
|
unloadDestroy: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: updateSizeDestroy
|
||||||
|
* When the map is destroyed, we need to stop listening to updateSize
|
||||||
|
* events: this method stores the function we need to unregister in
|
||||||
|
* non-IE browsers.
|
||||||
|
*/
|
||||||
|
updateSizeDestroy: null,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: destroy
|
* APIMethod: destroy
|
||||||
* Destroy this map
|
* Destroy this map
|
||||||
@@ -449,6 +459,13 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy);
|
||||||
this.unloadDestroy = null;
|
this.unloadDestroy = null;
|
||||||
|
|
||||||
|
if (this.updateSizeDestroy) {
|
||||||
|
OpenLayers.Event.stopObserving(window, 'resize',
|
||||||
|
this.updateSizeDestroy);
|
||||||
|
} else {
|
||||||
|
this.events.unregister("resize", this, this.updateSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.layers != null) {
|
if (this.layers != null) {
|
||||||
for (var i = this.layers.length - 1; i>=0; --i) {
|
for (var i = this.layers.length - 1; i>=0; --i) {
|
||||||
//pass 'false' to destroy so that map wont try to set a new
|
//pass 'false' to destroy so that map wont try to set a new
|
||||||
|
|||||||
Reference in New Issue
Block a user