[mapguide-commits] r5552 - trunk/MgDev/Common/CoordinateSystem

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Feb 15 18:25:01 EST 2011


Author: brucedechant
Date: 2011-02-15 15:25:01 -0800 (Tue, 15 Feb 2011)
New Revision: 5552

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

Notes:
- Added critical section around non-thread safe API


Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2011-02-15 23:21:53 UTC (rev 5551)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysFormatConverter.cpp	2011-02-15 23:25:01 UTC (rev 5552)
@@ -438,7 +438,7 @@
         throw new MgInvalidArgumentException(L"MgCoordinateSystemFormatConverter.CodeToWkt", __LINE__, __WFILE__, NULL, L"", NULL);
     }
 
-    const char* szMsiName=NULL;
+    std::string szMsiName;
     std::string strName;
 
     //if input is EPSG
@@ -467,8 +467,10 @@
             //viewed from the outside of public API
             //The mapping from Adsk name to Msi is done internally inside
             //the method CSepsg2adskCS
+            CriticalClass.Enter();
             szMsiName=CSepsg2adskCS(lEpsg);
-            if (!szMsiName)
+            CriticalClass.Leave();
+            if (szMsiName.empty())
             {
                 return L"";
             }
@@ -484,8 +486,8 @@
         strName=pszCsSource;
         delete[] pszCsSource;
         ReformatOldArbitraryName(strName);
-        szMsiName=strName.c_str();
-        if (!szMsiName)
+        szMsiName=strName;
+        if (szMsiName.empty())
         {
             return L"";
         }
@@ -500,7 +502,7 @@
     char csWktBufr [2048];
 
     //is it an arbitrary system, one that uses NERTH projection?
-    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.CodeToWkt", __LINE__, __WFILE__, NULL, L"", NULL);
@@ -523,7 +525,7 @@
     else
     {
         SmartCriticalClass critical(true);
-        if (0==CS_cs2Wkt(csWktBufr,sizeof(csWktBufr),szMsiName,GetWktFlavor(nWktFlavor)))
+        if (0==CS_cs2Wkt(csWktBufr,sizeof(csWktBufr),szMsiName.c_str(),GetWktFlavor(nWktFlavor)))
         {
             wchar_t* wszWkt=Convert_Ascii_To_Wide(csWktBufr);
             if (!wszWkt)



More information about the mapguide-commits mailing list