fixed memory leak in Marker.js. With manual test. p=rcoup, r=me (closes #2258)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9754 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2009-10-24 04:21:02 +00:00
parent 6c213ba86b
commit fd514e8435
2 changed files with 67 additions and 4 deletions

View File

@@ -78,7 +78,6 @@ OpenLayers.Marker = OpenLayers.Class({
this.icon.offset = newIcon.offset;
this.icon.calculateOffset = newIcon.calculateOffset;
}
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
},
/**
@@ -94,9 +93,6 @@ OpenLayers.Marker = OpenLayers.Class({
this.map = null;
this.events.destroy();
this.events = null;
if (this.icon != null) {
this.icon.destroy();
this.icon = null;
@@ -115,6 +111,9 @@ OpenLayers.Marker = OpenLayers.Class({
* location passed-in
*/
draw: function(px) {
if (!this.events) {
this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
}
return this.icon.draw(px);
},
@@ -126,6 +125,10 @@ OpenLayers.Marker = OpenLayers.Class({
if (this.icon != null) {
this.icon.erase();
}
if (this.events) {
this.events.destroy();
this.events = null;
}
},
/**