OpenLayers OpenLayers

Changeset 6172

Show
Ignore:
Timestamp:
02/09/08 13:51:48 (1 year ago)
Author:
ahocevar
Message:

Fixed several destroy() methods to avoid running into undefined objects when the page unloads. r=crschmidt,me (closes #1222)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Control.js

    r6167 r6172  
    167167    destroy: function () { 
    168168        this.events.destroy(); 
     169        this.events = null; 
    169170        // eliminate circular references 
    170171        if (this.handler) { 
  • trunk/openlayers/lib/OpenLayers/Control/Panel.js

    r6167 r6172  
    4646        OpenLayers.Control.prototype.destroy.apply(this, arguments); 
    4747        for(var i = this.controls.length - 1 ; i >= 0; i--) { 
    48             this.controls[i].events.un({ 
    49                 "activate": this.redraw, 
    50                 "deactivate": this.redraw, 
    51                 scope: this 
    52             }); 
     48            if(this.controls[i].events) { 
     49                this.controls[i].events.un({ 
     50                    "activate": this.redraw, 
     51                    "deactivate": this.redraw, 
     52                    scope: this 
     53                }); 
     54            } 
    5355            OpenLayers.Event.stopObservingElement(this.controls[i].panel_div); 
    5456            this.controls[i].panel_div = null; 
  • trunk/openlayers/lib/OpenLayers/Map.js

    r6149 r6172  
    486486        }     
    487487 
     488        if (this.controls != null) { 
     489            for (var i = this.controls.length - 1; i>=0; --i) { 
     490                this.controls[i].destroy(); 
     491            }  
     492            this.controls = null; 
     493        } 
    488494        if (this.layers != null) { 
    489495            for (var i = this.layers.length - 1; i>=0; --i) { 
     
    493499            }  
    494500            this.layers = null; 
    495         } 
    496         if (this.controls != null) { 
    497             for (var i = this.controls.length - 1; i>=0; --i) { 
    498                 this.controls[i].destroy(); 
    499             }  
    500             this.controls = null; 
    501501        } 
    502502        if (this.viewPortDiv) {