[mapguide-commits] r4536 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jan 15 02:04:39 EST 2010
Author: waltweltonlair
Date: 2010-01-15 02:04:37 -0500 (Fri, 15 Jan 2010)
New Revision: 4536
Modified:
trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
trunk/MgDev/Common/Stylization/SE_SymbolManager.cpp
Log:
Fix #1246 (Memory leak when using enhanced symbols with inlined images)
In the case of a symbol containing inlined image data (via the Content XML tag),
the data array is allocated and stored in the SE_Raster's ImageData member, but
it never gets freed. This problem does not happen for non-lined (referenced) images,
since in that case SE_SymbolManager caches the image data and frees it from its
destructor. So for the inlined case the SE_Raster must take ownership of the data.
SE_Raster was already set up to optionally own the data. All I had to do was turn
on the flag in the case of inlined image data.
I tested using both inlined and referenced image data, and in both cases the array
is now freed.
Also fixed a minor bug in which the default size of the image was being set to 5x5
instead of 1x1 (as specified by the schema).
Modified: trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp 2010-01-14 06:21:48 UTC (rev 4535)
+++ trunk/MgDev/Common/Stylization/SE_StyleVisitor.cpp 2010-01-15 07:04:37 UTC (rev 4536)
@@ -547,10 +547,17 @@
if (image.GetContent().size())
{
+ // we have inlined image data
const MdfModel::MdfString& src_u = image.GetContent();
if (m_resources)
+ {
m_resources->GetImageData(src_u.c_str(), (int)src_u.size(), primitive->imageData);
+
+ // the symbol manager call above does not cache the image data - the raster
+ // primitive must therefore take ownership of the data
+ primitive->ownPtr = true;
+ }
}
else
{
@@ -583,8 +590,8 @@
ParseDoubleExpression(image.GetPositionX(), primitive->position[0], 0.0);
ParseDoubleExpression(image.GetPositionY(), primitive->position[1], 0.0);
- ParseDoubleExpression(image.GetSizeX(), primitive->extent[0], 5.0);
- ParseDoubleExpression(image.GetSizeY(), primitive->extent[1], 5.0);
+ ParseDoubleExpression(image.GetSizeX(), primitive->extent[0], 1.0);
+ ParseDoubleExpression(image.GetSizeY(), primitive->extent[1], 1.0);
ParseDoubleExpression(image.GetAngle(), primitive->angleDeg, 0.0);
ParseBooleanExpression(image.GetSizeScalable(), primitive->sizeScalable, true);
ParseStringExpression(image.GetResizeControl(), primitive->resizeControl, GraphicElement::sResizeControlDefault, GraphicElement::sResizeControlValues);
Modified: trunk/MgDev/Common/Stylization/SE_SymbolManager.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_SymbolManager.cpp 2010-01-14 06:21:48 UTC (rev 4535)
+++ trunk/MgDev/Common/Stylization/SE_SymbolManager.cpp 2010-01-15 07:04:37 UTC (rev 4536)
@@ -25,6 +25,9 @@
// and the default implementation of this method converts the base64 data to
// PNG format. Override this method if you want to convert the base64 data
// to a different image format.
+//
+// The converted image data is stored in the supplied ImageData parameter,
+// and should not be cached by the symbol manager.
bool SE_SymbolManager::GetImageData(const wchar_t* base64Data, const int size, ImageData& imageData)
{
// strip out any non-base64 characters - you'll get these if the image
More information about the mapguide-commits
mailing list