[Commits] r1968 - core/trunk/geoext/lib/GeoExt/widgets

commits at geoext.org commits at geoext.org
Tue Mar 16 14:20:24 CET 2010


Author: bbinet
Date: 2010-03-16 14:20:24 +0100 (Tue, 16 Mar 2010)
New Revision: 1968

Modified:
   core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
Log:
check that layer.map is set before updating the WMSLegend item. r=elemoine (closes #238)

Modified: core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js
===================================================================
--- core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-03-16 12:54:13 UTC (rev 1967)
+++ core/trunk/geoext/lib/GeoExt/widgets/WMSLegend.js	2010-03-16 13:20:24 UTC (rev 1968)
@@ -123,7 +123,7 @@
         // styles data field and it is actually a GetLegendGraphic request.
         if(this.useScaleParameter === true &&
                 url.toLowerCase().indexOf("request=getlegendgraphic") != -1) {
-            var scale = layer.map.getScale();
+            var scale = this.map.getScale();
             //TODO replace with Ext.urlAppend when we drop support for Ext 2.x
             url = OpenLayers.Util.urlAppend(url, "SCALE=" + scale);
         }
@@ -136,11 +136,16 @@
      *  the per-sublayer box component.
      */
     update: function() {
+        var layer = this.layerRecord.get("layer");
+        // In some cases, this update function is called on a layer
+        // that has just been removed, see ticket #238.
+        // The following check bypass the update if map is not set.
+        if(!(layer && layer.map)) {
+            return;
+        }
         GeoExt.WMSLegend.superclass.update.apply(this, arguments);
         
         var layerNames, layerName, i, len;
-        
-        var layer = this.layerRecord.get("layer");
 
         layerNames = [layer.params.LAYERS].join(",").split(",");
 



More information about the Commits mailing list