[mapguide-commits] r7576 - branches/2.4/MgDev/Desktop/MapViewer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Jun 7 02:04:00 PDT 2013


Author: jng
Date: 2013-06-07 02:04:00 -0700 (Fri, 07 Jun 2013)
New Revision: 7576

Modified:
   branches/2.4/MgDev/Desktop/MapViewer/MgLegendControlPresenter.cs
Log:
#2248: The mg-desktop legend will still infinite loop on a background thread if we have groups not set to display in the legend. This submission handles this particular case.

Modified: branches/2.4/MgDev/Desktop/MapViewer/MgLegendControlPresenter.cs
===================================================================
--- branches/2.4/MgDev/Desktop/MapViewer/MgLegendControlPresenter.cs	2013-06-07 09:00:51 UTC (rev 7575)
+++ branches/2.4/MgDev/Desktop/MapViewer/MgLegendControlPresenter.cs	2013-06-07 09:04:00 UTC (rev 7576)
@@ -383,27 +383,27 @@
                     output.Add(node);
                     nodesById.Add(group.GetObjectId(), node);
                 }
+            }
 
-                while (remainingNodes.Count > 0)
+            while (remainingNodes.Count > 0)
+            {
+                List<MgLayerGroup> toRemove = new List<MgLayerGroup>();
+                for (int j = 0; j < remainingNodes.Count; j++)
                 {
-                    List<MgLayerGroup> toRemove = new List<MgLayerGroup>();
-                    for (int j = 0; j < remainingNodes.Count; j++)
+                    var parentId = remainingNodes[j].Group.GetObjectId();
+                    if (nodesById.ContainsKey(parentId))
                     {
-                        var parentId = remainingNodes[j].Group.GetObjectId();
-                        if (nodesById.ContainsKey(parentId))
-                        {
-                            var node = CreateGroupNode(remainingNodes[j]);
-                            nodesById[parentId].Nodes.Add(node);
-                            toRemove.Add(remainingNodes[j]);
-                        }
+                        var node = CreateGroupNode(remainingNodes[j]);
+                        nodesById[parentId].Nodes.Add(node);
+                        toRemove.Add(remainingNodes[j]);
                     }
-                    //Whittle down this list
-                    if (toRemove.Count > 0)
+                }
+                //Whittle down this list
+                if (toRemove.Count > 0)
+                {
+                    foreach (var g in toRemove)
                     {
-                        foreach (var g in toRemove)
-                        {
-                            remainingNodes.Remove(g);
-                        }
+                        remainingNodes.Remove(g);
                     }
                 }
             }
@@ -499,34 +499,40 @@
                             node.Expand();
                     }
                 }
+            }
 
-                while (remainingLayers.Count > 0)
+            while (remainingLayers.Count > 0)
+            {
+                List<MgLayerBase> toRemove = new List<MgLayerBase>();
+                for (int j = 0; j < remainingLayers.Count; j++)
                 {
-                    List<MgLayerBase> toRemove = new List<MgLayerBase>();
-                    for (int j = 0; j < remainingLayers.Count; j++)
+                    var parentGroup = remainingLayers[j].Group;
+                    var parentId = parentGroup.GetObjectId();
+                    if (nodesById.ContainsKey(parentId))
                     {
-                        var parentId = remainingLayers[j].Group.GetObjectId();
-                        if (nodesById.ContainsKey(parentId))
+                        var node = CreateLayerNode(remainingLayers[j]);
+                        if (node != null)
                         {
-                            var node = CreateLayerNode(remainingLayers[j]);
-                            if (node != null)
-                            {
-                                nodesById[parentId].Nodes.Add(node);
-                                if (remainingLayers[j].ExpandInLegend)
-                                    node.Expand();
-                            }
-                            toRemove.Add(remainingLayers[j]);
+                            nodesById[parentId].Nodes.Add(node);
+                            if (remainingLayers[j].ExpandInLegend)
+                                node.Expand();
                         }
+                        toRemove.Add(remainingLayers[j]);
                     }
-                    //Whittle down this list
-                    if (toRemove.Count > 0)
+                    else //Check parent group visibility. Could explain it
                     {
-                        foreach (var g in toRemove)
-                        {
-                            remainingLayers.Remove(g);
-                        }
+                        if (!parentGroup.GetDisplayInLegend())
+                            toRemove.Add(remainingLayers[j]);
                     }
                 }
+                //Whittle down this list
+                if (toRemove.Count > 0)
+                {
+                    foreach (var g in toRemove)
+                    {
+                        remainingLayers.Remove(g);
+                    }
+                }
             }
 
             //Now expand any relevant groups



More information about the mapguide-commits mailing list