OpenLayers OpenLayers

Changeset 2874

Show
Ignore:
Timestamp:
03/23/07 21:37:28 (2 years ago)
Author:
euzuro
Message:

applying (yet another) patch for #549. this one eliminates the double-destruction of the map due to the unload of window

Files:

Legend:

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

    r2863 r2874  
    3333    /** @type OpenLayers.Events */ 
    3434    events: null, 
     35 
     36    /** function that is called to destroy the map on page unload. stored 
     37     *   here so that if map is manually destroyed, we can unregister this. 
     38     *  
     39     * @type Function */ 
     40    unloadDestroy: null, 
    3541 
    3642    /** the div that our map lives in 
     
    213219        this.popups = new Array(); 
    214220 
     221        this.unloadDestroy = this.destroy.bindAsEventListener(this); 
     222         
     223 
    215224        // always call map.destroy() 
    216         OpenLayers.Event.observe(window,  
    217                       'unload',  
    218                       this.destroy.bindAsEventListener(this)); 
     225        OpenLayers.Event.observe(window, 'unload', this.unloadDestroy); 
    219226 
    220227    }, 
     
    224231    */ 
    225232    destroy:function() { 
     233 
     234        // map has been destroyed. dont do it again! 
     235        OpenLayers.Event.stopObserving(window, 'unload', this.unloadDestroy); 
     236        this.unloadDestroy = null; 
     237 
    226238        if (this.layers != null) { 
    227239            for(var i=0; i< this.layers.length; i++) { 
     
    242254        } 
    243255        this.viewPortDiv = null; 
     256 
     257        this.events.destroy(); 
     258        this.events = null; 
     259 
    244260    }, 
    245261