Changeset 862
- Timestamp:
- 05/23/09 08:21:00 (1 year ago)
- Files:
-
- core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js (modified) (1 diff)
- core/trunk/geoext/tests/lib/GeoExt/widgets/MapPanel.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
core/trunk/geoext/lib/GeoExt/widgets/MapPanel.js
r811 r862 171 171 }, 172 172 173 /** private: method[ onDestroy]173 /** private: method[beforeDestroy] 174 174 * Private method called during the destroy sequence. 175 175 */ 176 onDestroy: function() {176 beforeDestroy: function() { 177 177 if(this.ownerCt) { 178 178 this.ownerCt.un("move", this.updateMapSize, this); 179 179 } 180 GeoExt.MapPanel.superclass.onDestroy.apply(this, arguments); 180 /** 181 * If this container was passed a map instance, it is the 182 * responsibility of the creator to destroy it. 183 */ 184 if(!this.initialConfig.map || 185 !(this.initialConfig.map instanceof OpenLayers.Map)) { 186 // we created the map, we destroy it 187 if(this.map && this.map.destroy) { 188 this.map.destroy(); 189 } 190 } 191 delete this.map; 192 GeoExt.MapPanel.superclass.beforeDestroy.apply(this, arguments); 181 193 } 182 194 core/trunk/geoext/tests/lib/GeoExt/widgets/MapPanel.html
r855 r862 176 176 177 177 } 178 179 function test_destroy(t) { 180 181 /** 182 * If the panel is passed an instance of OpenLayers.Map, we don't 183 * touch it in the destroy sequence, we only remove our reference 184 * to it. If the panel is passed a map config object, the panel 185 * creates the OpenLayers.Map instance, and the panel destroys the 186 * map in its destroy sequence. 187 */ 188 189 t.plan(3); 190 191 var panel = new GeoExt.MapPanel({ 192 renderTo: "mappanel", 193 layers: [ 194 new OpenLayers.Layer("test") 195 ], 196 zoom: 1 197 }); 198 199 t.ok(panel.map instanceof OpenLayers.Map, "panel creates a map"); 200 201 var called = false; 202 panel.map.destroy = function() { 203 called = true; 204 OpenLayers.Map.prototype.destroy.apply(panel.map, arguments); 205 } 206 try { 207 panel.destroy(); 208 t.ok(called, "panel.destroy calls map.destroy"); 209 } catch(err) { 210 t.fail("panel.destroy causes problems: " + err); 211 } 212 t.ok(!panel.map, "panel has no reference to a map"); 213 214 } 178 215 179 216