[mapguide-commits] r5686 - sandbox/adsk/2.3r/Common/CoordinateSystem

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Apr 6 12:17:52 EDT 2011


Author: brucedechant
Date: 2011-04-06 09:17:52 -0700 (Wed, 06 Apr 2011)
New Revision: 5686

Modified:
   sandbox/adsk/2.3r/Common/CoordinateSystem/CoordSysFormatConverter.cpp
Log:
Fix for trac ticket 1600 - Threading error with CodeToWkt() method
http://trac.osgeo.org/mapguide/ticket/1600

Notes:
- Guard all CSepsg2adskCS() method calls


Modified: sandbox/adsk/2.3r/Common/CoordinateSystem/CoordSysFormatConverter.cpp
===================================================================
--- sandbox/adsk/2.3r/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2011-04-06 14:35:13 UTC (rev 5685)
+++ sandbox/adsk/2.3r/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2011-04-06 16:17:52 UTC (rev 5686)
@@ -812,7 +812,7 @@
         throw new MgOutOfMemoryException(L"MgCoordinateSystemFormatConverter.CodeToDefinition", __LINE__, __WFILE__, NULL, L"", NULL);
     }
 
-    const char* szMsiName=NULL;
+    std::string szMsiName;
 
     //if input is EPSG
     bool bResult=false;
@@ -826,9 +826,20 @@
             //viewed from the outside of the public API
             //The mapping from Adsk name to Msi is done internally inside
             //the method CSepsg2adskCS
-            szMsiName=CSepsg2adskCS(lEpsg);
-            if (szMsiName)
+            CriticalClass.Enter();
+            const char* szMsiNameTemp=NULL;
+            szMsiNameTemp=CSepsg2adskCS(lEpsg);
+            if(NULL == szMsiNameTemp)
             {
+                szMsiName = "";
+            }
+            else
+            {
+                szMsiName = szMsiNameTemp;
+            }
+            CriticalClass.Leave();
+            if (!szMsiName.empty())
+            {
                 bResult=true;
             }
         }
@@ -847,9 +858,9 @@
     //now get the definition
     if (bResult)
     {
-        assert(szMsiName);
+        assert(!szMsiName.empty());
 
-        wchar_t* wszMsiName=Convert_Ascii_To_Wide(szMsiName);
+        wchar_t* wszMsiName=Convert_Ascii_To_Wide(szMsiName.c_str());
         if (!wszMsiName)
         {
             throw new MgOutOfMemoryException(L"MgCoordinateSystemFormatConverter.CodeToDefinition", __LINE__, __WFILE__, NULL, L"", NULL);
@@ -902,14 +913,26 @@
                 //viewed from the outside of the public API
                 //The mapping from Adsk name to Msi is done internally inside
                 //the method CSepsg2adskCS
-                const char* szMsiName=CSepsg2adskCS(lEpsg);
-                if (szMsiName)
+                std::string szMsiName;
+                CriticalClass.Enter();
+                const char* szMsiNameTemp=NULL;
+                szMsiNameTemp=CSepsg2adskCS(lEpsg);
+                if(NULL == szMsiNameTemp)
                 {
+                    szMsiName = "";
+                }
+                else
+                {
+                    szMsiName = szMsiNameTemp;
+                }
+                CriticalClass.Leave();
+                if (!szMsiName.empty())
+                {
                     //need to check if the system is in our dictionary
-                    bool bIsCoordinateSystem=IsCoordinateSystem(const_cast<char*>(szMsiName), NULL);
+                    bool bIsCoordinateSystem=IsCoordinateSystem(const_cast<char*>(szMsiName.c_str()), NULL);
                     if (bIsCoordinateSystem)
                     {
-                        wchar_t *pwszCsDestination=Convert_Ascii_To_Wide(szMsiName);
+                        wchar_t *pwszCsDestination=Convert_Ascii_To_Wide(szMsiName.c_str());
                         if (!pwszCsDestination)
                         {
                             throw new MgOutOfMemoryException(L"MgCoordinateSystemFormatConverter.CodeToCode", __LINE__, __WFILE__, NULL, L"", NULL);
@@ -991,9 +1014,21 @@
             //viewed from the outside of the public API
             //The mapping from Adsk name to Msi is done internally inside
             //the method CSepsg2adskCS
-            const char* szMsiName=CSepsg2adskCS(lEpsg);
-            if (szMsiName)
+            std::string szMsiName;
+            CriticalClass.Enter();
+            const char* szMsiNameTemp=NULL;
+            szMsiNameTemp=CSepsg2adskCS(lEpsg);
+            if(NULL == szMsiNameTemp)
             {
+                szMsiName = "";
+            }
+            else
+            {
+                szMsiName = szMsiNameTemp;
+            }
+            CriticalClass.Leave();
+            if (!szMsiName.empty())
+            {
                 //we may have found an Msi name for a system
                 //but we still have to check if the system is in the dicionary
                 //in CS_epsg.c I found some systems that were present in the mapping
@@ -1002,7 +1037,7 @@
                 //if the system is in the dictionary since it takes care
                 //of mapping an MSI name to a valid ADSK name
                 //We'll check the existence of the system for additional security
-                bIsPresent=IsCoordinateSystem(const_cast<char*>(szMsiName), NULL);
+                bIsPresent=IsCoordinateSystem(const_cast<char*>(szMsiName.c_str()), NULL);
             }
         }
     }



More information about the mapguide-commits mailing list