[mapguide-commits] r6939 - in branches/2.4/MgDev/Desktop/MgDesktop/Services: . Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Aug 20 01:32:45 PDT 2012


Author: jng
Date: 2012-08-20 01:32:45 -0700 (Mon, 20 Aug 2012)
New Revision: 6939

Modified:
   branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/GwsFeatureReader.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp
   branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp
Log:
Fix incorrect implementation of GetString(CREFSTRING, INT32& ) for all applicable readers. These readers follow the aggressive implementation as proposed in #1766, however this particular method in all the reader implementations should still go through the conservative approach (ie. IsNull() check first). This problem was exposed with the introduction of r6937. This submission fixes that.

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp	2012-08-16 12:51:25 UTC (rev 6938)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/DataReader.cpp	2012-08-20 08:32:45 UTC (rev 6939)
@@ -677,28 +677,23 @@
 
     MG_FEATURE_SERVICE_TRY()
 
-    try
+    if(m_reader->IsNull(propertyName.c_str()))
     {
+        MgStringCollection arguments;
+        arguments.Add(propertyName);
+
+        throw new MgNullPropertyValueException(L"MgdDataReader::GetString",
+            __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+    else
+    {
         retVal = m_reader->GetString(propertyName.c_str());
         if (retVal != NULL)
         {
             length = (INT32)wcslen((const wchar_t*)retVal);
         }
     }
-    catch(...)
-    {
-        if(m_reader->IsNull(propertyName.c_str()))
-        {
-            MgStringCollection arguments;
-            arguments.Add(propertyName);
 
-            throw new MgNullPropertyValueException(L"MgdDataReader::GetString",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
-        }
-        else
-            throw;
-    }
-
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdDataReader::GetString");
 
     return ((const wchar_t*)retVal);

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/GwsFeatureReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/GwsFeatureReader.cpp	2012-08-16 12:51:25 UTC (rev 6938)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/Feature/GwsFeatureReader.cpp	2012-08-20 08:32:45 UTC (rev 6939)
@@ -1417,32 +1417,27 @@
     IGWSFeatureIterator* gwsFeatureIter = NULL;
     STRING parsedPropertyName;
     DeterminePropertyFeatureSource(propertyName, &gwsFeatureIter, parsedPropertyName);
-    CHECKNULL(gwsFeatureIter, L"MgdGwsFeatureReader.GetString");
+    CHECKNULL(gwsFeatureIter, L"MgdGwsFeatureReader::GetString");
 
-    try
+    if(gwsFeatureIter->IsNull(parsedPropertyName.c_str()))
     {
+        MgStringCollection arguments;
+        arguments.Add(propertyName);
+
+        throw new MgNullPropertyValueException(L"MgdGwsFeatureReader::GetString",
+            __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+    else
+    {
         retVal = gwsFeatureIter->GetString(parsedPropertyName.c_str());
         if (retVal != NULL)
         {
             length = (INT32)wcslen((const wchar_t*)retVal);
         }
     }
-    catch(...)
-    {
-        if(gwsFeatureIter->IsNull(parsedPropertyName.c_str()))
-        {
-            MgStringCollection arguments;
-            arguments.Add(propertyName);
 
-            throw new MgNullPropertyValueException(L"MgdGwsFeatureReader.GetString",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
-        }
-        else
-            throw;
-    }
+    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdGwsFeatureReader::GetString");
 
-    MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdGwsFeatureReader.GetString");
-
     return ((const wchar_t*)retVal);
 }
 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp	2012-08-16 12:51:25 UTC (rev 6938)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/FeatureReader.cpp	2012-08-20 08:32:45 UTC (rev 6939)
@@ -649,35 +649,32 @@
 
 const wchar_t* MgdFeatureReader::GetString(CREFSTRING propertyName, INT32& length) 
 { 
-	FdoString* ret = NULL;
+	CHECKNULL(m_reader, L"MgdFeatureReader::GetString");
 
+    FdoString* retVal = NULL;
+
     MG_FEATURE_SERVICE_TRY()
 
-    try
+    if(m_reader->IsNull(propertyName.c_str()))
     {
-        ret = m_reader->GetString(propertyName.c_str());
-        if (ret != NULL)
-        {
-            length = (INT32)wcslen((const wchar_t*)ret);
-        }
+        MgStringCollection arguments;
+        arguments.Add(propertyName);
+
+        throw new MgNullPropertyValueException(L"MgdFeatureReader::GetString",
+            __LINE__, __WFILE__, &arguments, L"", NULL);
     }
-    catch(...)
+    else
     {
-        if(m_reader->IsNull(propertyName.c_str()))
+        retVal = m_reader->GetString(propertyName.c_str());
+        if (retVal != NULL)
         {
-            MgStringCollection arguments;
-            arguments.Add(propertyName);
-
-            throw new MgNullPropertyValueException(L"MgdFeatureReader::GetString",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
+            length = (INT32)wcslen((const wchar_t*)retVal);
         }
-        else
-            throw;
     }
 
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdFeatureReader::GetString");
 
-    return ((const wchar_t*)ret);
+    return ((const wchar_t*)retVal);
 }
 
 void MgdFeatureReader::Serialize(MgStream* stream) 

Modified: branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp
===================================================================
--- branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp	2012-08-16 12:51:25 UTC (rev 6938)
+++ branches/2.4/MgDev/Desktop/MgDesktop/Services/SqlReader.cpp	2012-08-20 08:32:45 UTC (rev 6939)
@@ -603,28 +603,23 @@
 
     MG_FEATURE_SERVICE_TRY()
 
-    try
+    if(m_reader->IsNull(propertyName.c_str()))
     {
+        MgStringCollection arguments;
+        arguments.Add(propertyName);
+
+        throw new MgNullPropertyValueException(L"MgdSqlDataReader::GetString",
+            __LINE__, __WFILE__, &arguments, L"", NULL);
+    }
+    else
+    {
         retVal = m_reader->GetString(propertyName.c_str());
         if (retVal != NULL)
         {
             length = (INT32)wcslen((const wchar_t*)retVal);
         }
     }
-    catch(...)
-    {
-        if(m_reader->IsNull(propertyName.c_str()))
-        {
-            MgStringCollection arguments;
-            arguments.Add(propertyName);
 
-            throw new MgNullPropertyValueException(L"MgdSqlDataReader::GetString",
-                __LINE__, __WFILE__, &arguments, L"", NULL);
-        }
-        else
-            throw;
-    }
-
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgdSqlDataReader::GetString");
 
     return ((const wchar_t*)retVal);



More information about the mapguide-commits mailing list