[mapguide-commits] r6047 - in trunk/MgDev/Common: MdfModel MdfParser

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Aug 8 11:55:46 EDT 2011


Author: waltweltonlair
Date: 2011-08-08 08:55:46 -0700 (Mon, 08 Aug 2011)
New Revision: 6047

Modified:
   trunk/MgDev/Common/MdfModel/URLData.cpp
   trunk/MgDev/Common/MdfModel/URLData.h
   trunk/MgDev/Common/MdfModel/VectorLayerDefinition.cpp
   trunk/MgDev/Common/MdfModel/VectorLayerDefinition.h
   trunk/MgDev/Common/MdfParser/IOURLData.cpp
   trunk/MgDev/Common/MdfParser/IOURLData.h
   trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
Log:
Fix issues with RFC119 submission

MdfModel\VectorLayerDefinition.cpp
- memory leak: AdoptUrlData must delete any existing URLData object if called with a new object
- don't check for null before deleting objects

MdfModel\URLData.h
- year was missing in header block

MdfModel\URLData.cpp
MdfParser\IOURLData.h
MdfParser\IOURLData.cpp
- year was incorrect in header block


Unrelated to RFC119 submission
- remove unused m_strKey member variable from VectorLayerDefinition


Modified: trunk/MgDev/Common/MdfModel/URLData.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/URLData.cpp	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfModel/URLData.cpp	2011-08-08 15:55:46 UTC (rev 6047)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2004-2011 by Autodesk, Inc.
+//  Copyright (C) 2011 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -19,6 +19,7 @@
 // DESCRIPTION:
 // The URLData class implementation.
 //-------------------------------------------------------------------------
+
 #include "stdafx.h"
 #include "URLData.h"
 
@@ -104,4 +105,3 @@
 {
     this->m_strUrlDescriptionOverride = urlDescriptionOverride;
 }
-

Modified: trunk/MgDev/Common/MdfModel/URLData.h
===================================================================
--- trunk/MgDev/Common/MdfModel/URLData.h	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfModel/URLData.h	2011-08-08 15:55:46 UTC (rev 6047)
@@ -1,3 +1,6 @@
+//
+//  Copyright (C) 2011 by Autodesk, Inc.
+//
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
 //  General Public License as published by the Free Software Foundation.
@@ -19,12 +22,13 @@
 #include "MdfRootObject.h"
 
 BEGIN_NAMESPACE_MDFMODEL
+
     //-------------------------------------------------------------------------
     // DESCRIPTION:
     // The URLData class is used by a layer to provide URL information for each 
     // feature.
     //-------------------------------------------------------------------------
-class MDFMODEL_API URLData : public MdfRootObject
+    class MDFMODEL_API URLData : public MdfRootObject
     {
         public:
             // Construction, destruction, initialization
@@ -65,6 +69,6 @@
             //URL description override
             MdfString m_strUrlDescriptionOverride;
     };
+
 END_NAMESPACE_MDFMODEL
 #endif
-

Modified: trunk/MgDev/Common/MdfModel/VectorLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfModel/VectorLayerDefinition.cpp	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfModel/VectorLayerDefinition.cpp	2011-08-08 15:55:46 UTC (rev 6047)
@@ -45,10 +45,7 @@
 //-------------------------------------------------------------------------
 VectorLayerDefinition::~VectorLayerDefinition()
 {
-    if(m_urlData != NULL)
-    {
-        delete this->m_urlData;
-    }
+    delete this->m_urlData;
 }
 
 //-------------------------------------------------------------------------
@@ -141,7 +138,11 @@
 //-------------------------------------------------------------------------
 void VectorLayerDefinition::AdoptUrlData(URLData* urlData)
 {
-    this->m_urlData = urlData;
+    if (this->m_urlData != urlData)
+    {
+        delete this->m_urlData;
+        this->m_urlData = urlData;
+    }
 }
 
 //-------------------------------------------------------------------------

Modified: trunk/MgDev/Common/MdfModel/VectorLayerDefinition.h
===================================================================
--- trunk/MgDev/Common/MdfModel/VectorLayerDefinition.h	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfModel/VectorLayerDefinition.h	2011-08-08 15:55:46 UTC (rev 6047)
@@ -54,6 +54,10 @@
         FeatureNameType GetFeatureNameType() const;
         void SetFeatureNameType(FeatureNameType featureNameType);
 
+        // Property : Filter
+        const MdfString& GetFilter() const;
+        void SetFilter(const MdfString& strFilter);
+
         // Property : Properties
         NameStringPairCollection* GetPropertyMappings();
 
@@ -61,7 +65,7 @@
         const MdfString& GetGeometry() const;
         void SetGeometry(const MdfString&  strGeometry);
 
-        // Property : Url
+        // Property : UrlData
         URLData* GetUrlData();
         void AdoptUrlData(URLData* urlData);
 
@@ -69,10 +73,6 @@
         const MdfString& GetToolTip() const;
         void SetToolTip(const MdfString&  strToolTip);
 
-        // Property : Filter
-        const MdfString& GetFilter() const;
-        void SetFilter(const MdfString& strFilter);
-
         // Property : VectorScaleRanges
         VectorScaleRangeCollection* GetScaleRanges();
 
@@ -94,13 +94,10 @@
         // Stores an SQL Where clause for returning the appropriate feature.
         MdfString m_strFilter;
 
-        // Key
-        MdfString m_strKey;
-
         // Geometry
         MdfString m_strGeometry;
 
-        // Url
+        // UrlData
         URLData* m_urlData;
 
         // ToolTip

Modified: trunk/MgDev/Common/MdfParser/IOURLData.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOURLData.cpp	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfParser/IOURLData.cpp	2011-08-08 15:55:46 UTC (rev 6047)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2007-2011 by Autodesk, Inc.
+//  Copyright (C) 2011 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -14,6 +14,7 @@
 //  License along with this library; if not, write to the Free Software
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
+
 #include "stdafx.h"
 #include "IOURLData.h"
 #include "IOUnknown.h"
@@ -30,6 +31,7 @@
 ELEM_MAP_ENTRY(5, DescriptionOverride);
 ELEM_MAP_ENTRY(6, ExtendedData1);
 
+
 IOURLData::IOURLData(Version& version) : SAX2ElementHandler(version)
 {
     this->m_urlData = NULL;
@@ -131,6 +133,14 @@
         fd << endStr(sContent) << std::endl;
     }
 
+    // Property: Description
+    if(!urlData->GetUrlDescription().empty())
+    {
+        fd << tab.tab() << startStr(sDescription);
+        fd << EncodeString(urlData->GetUrlDescription());
+        fd << endStr(sDescription) << std::endl;
+    }
+
     // Property: Content Override
     if(!urlData->GetUrlContentOverride().empty())
     {
@@ -139,14 +149,6 @@
         fd << endStr(sContentOverride) << std::endl;
     }
 
-    // Property: Description
-    if(!urlData->GetUrlDescription().empty())
-    {
-        fd << tab.tab() << startStr(sDescription);
-        fd << EncodeString(urlData->GetUrlDescription());
-        fd << endStr(sDescription) << std::endl;
-    }
-
     // Property: Description Override
     if(!urlData->GetUrlDescriptionOverrride().empty())
     {

Modified: trunk/MgDev/Common/MdfParser/IOURLData.h
===================================================================
--- trunk/MgDev/Common/MdfParser/IOURLData.h	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfParser/IOURLData.h	2011-08-08 15:55:46 UTC (rev 6047)
@@ -1,5 +1,5 @@
 //
-//  Copyright (C) 2007-2011 by Autodesk, Inc.
+//  Copyright (C) 2011 by Autodesk, Inc.
 //
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser

Modified: trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp
===================================================================
--- trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2011-08-08 15:44:36 UTC (rev 6046)
+++ trunk/MgDev/Common/MdfParser/IOVectorLayerDefinition.cpp	2011-08-08 15:55:46 UTC (rev 6047)
@@ -149,24 +149,24 @@
         this->m_layer->SetFilter(ch);
         break;
 
+    case eGeometry:
+        this->m_layer->SetGeometry(ch);
+        break;
+
     case eUrl:
-        //Handle layer definition <= 2.3.0
-        if(m_version < Version(2, 4, 0))
+        // Handle layer definition <= 2.3.0
+        if (m_version <= Version(2, 3, 0))
         {
-            URLData* urlData =  this->m_layer->GetUrlData();
-            if(!urlData)
+            URLData* urlData = this->m_layer->GetUrlData();
+            if (!urlData)
             {
                 urlData = new URLData();
+                this->m_layer->AdoptUrlData(urlData);
             }
             urlData->SetUrlContent(ch);
-            this->m_layer->AdoptUrlData(urlData);
         }
         break;
 
-    case eGeometry:
-        this->m_layer->SetGeometry(ch);
-        break;
-
     case eToolTip:
         this->m_layer->SetToolTip(ch);
         break;
@@ -318,24 +318,26 @@
     fd << EncodeString(vectorLayer->GetGeometry());
     fd << endStr(sGeometry) << std::endl;
 
-    // Property: Url
+    // Property: Url / UrlData
     URLData* urlData = vectorLayer->GetUrlData();
-    if(urlData)
+    if (urlData)
     {
-        if(!version || (*version >= Version(2, 4, 0)))
+        if (!version || (*version >= Version(2, 4, 0)))
         {
+            // write new version 2.4.0 property
             IOURLData::Write(fd, urlData, version, tab);
         }
         else
         {
-            // For layer definition version <= 2.3.0
-            if(!urlData->GetUrlContent().empty())
+            // save original url property for LDF versions <= 2.3.0
+            if (!urlData->GetUrlContent().empty())
             {
                 fd << tab.tab() << startStr(sUrl);
                 fd << EncodeString(urlData->GetUrlContent());
                 fd << endStr(sUrl) << std::endl;
             }
-            //In extended data
+
+            // save new property as extended data for LDF versions <= 2.3.0
             tab.inctab();
             IOURLData::Write(fdExtData, urlData, version, tab);
             tab.dectab();



More information about the mapguide-commits mailing list