[mapguide-commits] r4306 - in trunk/MgDev/Server/src/Services: Kml Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sat Oct 17 04:48:58 EDT 2009


Author: waltweltonlair
Date: 2009-10-17 04:48:57 -0400 (Sat, 17 Oct 2009)
New Revision: 4306

Modified:
   trunk/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
   trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
Log:
Fix ref count memory leaks involving MgLayerBase::GetLayerDefinition usage.  The method
addref's the resource identifier.  If you call it you have to release it.......


Modified: trunk/MgDev/Server/src/Services/Kml/ServerKmlService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2009-10-17 06:55:41 UTC (rev 4305)
+++ trunk/MgDev/Server/src/Services/Kml/ServerKmlService.cpp	2009-10-17 08:48:57 UTC (rev 4306)
@@ -312,7 +312,8 @@
     kmlContent.WriteString("<href>");
     kmlContent.WriteString(agentUri, false);
     kmlContent.WriteString("?OPERATION=GetLayerKml&amp;VERSION=1.0.0&amp;LAYERDEFINITION=", false);
-    kmlContent.WriteString(MgUtil::WideCharToMultiByte(layer->GetLayerDefinition()->ToString()), false);
+    Ptr<MgResourceIdentifier> resource = layer->GetLayerDefinition();
+    kmlContent.WriteString(MgUtil::WideCharToMultiByte(resource->ToString()), false);
     sprintf(buffer,"&amp;DRAWORDER=%d", drawOrder);
     kmlContent.WriteString(buffer, false);
     kmlContent.WriteString("&amp;FORMAT=", false);
@@ -351,7 +352,8 @@
     kmlContent.WriteString("<href>");
     kmlContent.WriteString(agentUri, false);
     kmlContent.WriteString("?OPERATION=GetFeaturesKml&amp;VERSION=1.0.0&amp;LAYERDEFINITION=", false);
-    kmlContent.WriteString(MgUtil::WideCharToMultiByte(layer->GetLayerDefinition()->ToString()), false);
+    Ptr<MgResourceIdentifier> resource = layer->GetLayerDefinition();
+    kmlContent.WriteString(MgUtil::WideCharToMultiByte(resource->ToString()), false);
     sprintf(buffer,"&amp;DPI=%f", dpi);
     kmlContent.WriteString(buffer, false);
     sprintf(buffer,"&amp;DRAWORDER=%d", drawOrder);
@@ -401,7 +403,8 @@
     kmlContent.WriteString("<href>");
     kmlContent.WriteString(agentUri, false);
     kmlContent.WriteString("?OPERATION=GetFeaturesKml&amp;VERSION=1.0.0&amp;LAYERDEFINITION=", false);
-    kmlContent.WriteString(MgUtil::WideCharToMultiByte(layer->GetLayerDefinition()->ToString()), false);
+    Ptr<MgResourceIdentifier> resource = layer->GetLayerDefinition();
+    kmlContent.WriteString(MgUtil::WideCharToMultiByte(resource->ToString()), false);
     sprintf(buffer,"&amp;DPI=%f", dpi);
     kmlContent.WriteString(buffer, false);
     kmlContent.WriteString("&amp;FORMAT=", false);

Modified: trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-10-17 06:55:41 UTC (rev 4305)
+++ trunk/MgDev/Server/src/Services/Mapping/MappingUtil.cpp	2009-10-17 08:48:57 UTC (rev 4306)
@@ -388,7 +388,8 @@
                 continue;
         }
 
-        layerIds->Add(mapLayer->GetLayerDefinition()->ToString());
+        Ptr<MgResourceIdentifier> mapLayerId = mapLayer->GetLayerDefinition();
+        layerIds->Add(mapLayerId->ToString());
     }
     if(layerIds->GetCount() != 0)
     {
@@ -398,7 +399,8 @@
             for(int j = 0; j < layers->GetCount(); j ++)
             {
                 Ptr<MgLayerBase> mapLayer = layers->GetItem(j);
-                if(mapLayer->GetLayerDefinition()->ToString() == layerIds->GetItem(i))
+                Ptr<MgResourceIdentifier> mapLayerId = mapLayer->GetLayerDefinition();
+                if(mapLayerId->ToString() == layerIds->GetItem(i))
                 {
                     mapLayer->SetLayerResourceContent(layerContents->GetItem(i));
                     break;



More information about the mapguide-commits mailing list