[mapguide-commits] r6535 - sandbox/adsk/2.4j/Server/src/Services/Mapping

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Mar 8 21:21:17 EST 2012


Author: liuar
Date: 2012-03-08 18:21:17 -0800 (Thu, 08 Mar 2012)
New Revision: 6535

Modified:
   sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp
Log:
Submit on behalf of Mars Wu
Fix Ticket: http://trac.osgeo.org/mapguide/ticket/1961
Following line is executed in StylizeLayers?() function:

STRING layerWkt = layerCs->ToString();

layerCs will be NULL if there is no CS or CS override specified for the feature source. Then NULL pointer exception will happen in above line. On Windows, there is a macro MG_CATCH_AND_RELEASE() to catch this exception and simply continue the logic.

#define MG_CATCH_AND_RELEASE() \
} \
catch (MgException* e) \
{ \
mgException = e; \
} \
catch (...) \
{ \
}

However, on Linux, NULL pointer will lead to Segmentation Fault, which cannot be caught by catch (...) and will crash the application directly. So the pointer has to be verified before calling any methods of the pointer to avoid Segmentation Fault crash on Linux


Modified: sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp
===================================================================
--- sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp	2012-03-05 02:36:31 UTC (rev 6534)
+++ sandbox/adsk/2.4j/Server/src/Services/Mapping/MappingUtil.cpp	2012-03-09 02:21:17 UTC (rev 6535)
@@ -660,7 +660,7 @@
                     // On error, ignore the exception and use the original extent.
                     MG_TRY()
                     Ptr<MgSpatialContextReader> contextReader = svcFeature->GetSpatialContexts(featResId, false);
-                    STRING layerWkt = layerCs->ToString();
+                    STRING layerWkt = (NULL == layerCs.p) ? L"" : layerCs->ToString();
                     while (contextReader.p != NULL && contextReader->ReadNext())
                     {
                         // Try to find wkt for feature's coordinate system



More information about the mapguide-commits mailing list