[mapguide-commits] r4539 - sandbox/adsk/2.2gp/Common/Stylization

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jan 19 16:13:53 EST 2010


Author: waltweltonlair
Date: 2010-01-19 16:13:53 -0500 (Tue, 19 Jan 2010)
New Revision: 4539

Modified:
   sandbox/adsk/2.2gp/Common/Stylization/SE_StyleVisitor.cpp
   sandbox/adsk/2.2gp/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.2gp/Common/Stylization/SE_StyleVisitor.cpp
===================================================================
--- sandbox/adsk/2.2gp/Common/Stylization/SE_StyleVisitor.cpp	2010-01-15 20:33:56 UTC (rev 4538)
+++ sandbox/adsk/2.2gp/Common/Stylization/SE_StyleVisitor.cpp	2010-01-19 21:13:53 UTC (rev 4539)
@@ -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: sandbox/adsk/2.2gp/Common/Stylization/SE_SymbolManager.cpp
===================================================================
--- sandbox/adsk/2.2gp/Common/Stylization/SE_SymbolManager.cpp	2010-01-15 20:33:56 UTC (rev 4538)
+++ sandbox/adsk/2.2gp/Common/Stylization/SE_SymbolManager.cpp	2010-01-19 21:13:53 UTC (rev 4539)
@@ -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