[mapguide-commits] r5567 -
branches/2.2/MgDev/Common/PlatformBase/MapLayer
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Sat Feb 26 09:26:57 EST 2011
Author: trevorwekel
Date: 2011-02-26 06:26:56 -0800 (Sat, 26 Feb 2011)
New Revision: 5567
Modified:
branches/2.2/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
Log:
Ticket #1601 MgLayer constructor is not thread safe
- Submit fix to branches/2.2
Modified: branches/2.2/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
===================================================================
--- branches/2.2/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp 2011-02-25 21:58:45 UTC (rev 5566)
+++ branches/2.2/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp 2011-02-26 14:26:56 UTC (rev 5567)
@@ -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