[mapguide-commits] r4537 - sandbox/adsk/2.1/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Fri Jan 15 14:11:17 EST 2010
Author: waltweltonlair
Date: 2010-01-15 14:11:15 -0500 (Fri, 15 Jan 2010)
New Revision: 4537
Modified:
sandbox/adsk/2.1/Common/Stylization/SE_StyleVisitor.cpp
sandbox/adsk/2.1/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: sandbox/adsk/2.1/Common/Stylization/SE_StyleVisitor.cpp
===================================================================
--- sandbox/adsk/2.1/Common/Stylization/SE_StyleVisitor.cpp 2010-01-15 07:04:37 UTC (rev 4536)
+++ sandbox/adsk/2.1/Common/Stylization/SE_StyleVisitor.cpp 2010-01-15 19:11:15 UTC (rev 4537)
@@ -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);
@@ -847,8 +854,8 @@
ParseStringExpression(instance->GetPositioningAlgorithm(), m_symbolInstance->positioningAlgorithm, SymbolInstance::sPositioningAlgorithmDefault, SymbolInstance::sPositioningAlgorithmValues);
ParseBooleanExpression(instance->GetDrawLast(), m_symbolInstance->drawLast, false);
- ParseBooleanExpression(instance->GetAddToExclusionRegion(), m_symbolInstance->addToExclusionRegions, false);
- ParseBooleanExpression(instance->GetCheckExclusionRegion(), m_symbolInstance->checkExclusionRegions, false);
+ ParseBooleanExpression(instance->GetAddToExclusionRegion(), m_symbolInstance->addToExclusionRegion, false);
+ ParseBooleanExpression(instance->GetCheckExclusionRegion(), m_symbolInstance->checkExclusionRegion, false);
ParseDoubleExpression(instance->GetScaleX(), m_symbolInstance->scale[0], 1.0);
ParseDoubleExpression(instance->GetScaleY(), m_symbolInstance->scale[1], 1.0);
Modified: sandbox/adsk/2.1/Common/Stylization/SE_SymbolManager.cpp
===================================================================
--- sandbox/adsk/2.1/Common/Stylization/SE_SymbolManager.cpp 2010-01-15 07:04:37 UTC (rev 4536)
+++ sandbox/adsk/2.1/Common/Stylization/SE_SymbolManager.cpp 2010-01-15 19:11:15 UTC (rev 4537)
@@ -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