[mapguide-commits] r5595 - trunk/MgDev/Common/PlatformBase/MapLayer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Mar 3 19:13:45 EST 2011
Author: trevorwekel
Date: 2011-03-03 16:13:45 -0800 (Thu, 03 Mar 2011)
New Revision: 5595
Modified:
trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
Log:
Ticket #1601 MgLayer constructor is not thread safe
Submit to trunk
Modified: trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp 2011-03-03 19:47:06 UTC (rev 5594)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp 2011-03-04 00:13:45 UTC (rev 5595)
@@ -637,10 +637,33 @@
}
else
{
- ldf.reset(MgLayerBase::GetLayerDefinition(resourceService, m_definition));
+ Ptr<MgResourceIdentifier> resourceId = MgLayerBase::GetLayerDefinition();
+ // get and parse the layer definition
+ Ptr<MgByteReader> reader = resourceService->GetResourceContent(resourceId, L"");
+ Ptr<MgByteSink> sink = new MgByteSink(reader);
+ Ptr<MgByte> bytes = sink->ToBuffer();
+
+ assert(bytes->GetLength() > 0);
+
+ MdfParser::SAX2Parser parser;
+ parser.ParseString((const char*)bytes->Bytes(), bytes->GetLength());
+
+ if (!parser.GetSucceeded())
+ {
+ STRING errorMsg = parser.GetErrorMessage();
+ MgStringCollection arguments;
+ arguments.Add(errorMsg);
+ throw new MgInvalidLayerDefinitionException(L"MgLayerBase::GetLayerDefinition", __LINE__, __WFILE__, &arguments, L"", NULL);
+ }
+
+ MdfModel::LayerDefinition* ldef = parser.DetachLayerDefinition();
+ assert(ldef != NULL);
+
+ ldf.reset(ldef);
+
//cache the resource content
- MdfParser::SAX2Parser parser;
- std::string content = parser.SerializeToXML(ldf.get(), NULL);
+ std::string content;
+ content.assign((const char*) bytes->Bytes(), bytes->GetLength());
MgUtil::MultiByteToWideChar(content, m_resourceContent);
}
More information about the mapguide-commits
mailing list