[mapguide-commits] r5134 - trunk/MgDev/Common/Stylization
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Sep 16 16:40:44 EDT 2010
Author: waltweltonlair
Date: 2010-09-16 20:40:44 +0000 (Thu, 16 Sep 2010)
New Revision: 5134
Modified:
trunk/MgDev/Common/Stylization/SE_LineRenderer.cpp
trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
Log:
SE_LineRenderer::ProcessLineOverlapWrap would hang if the supplied style contained no primitives. Add a check to prevent this.
Also added the check to a few other places to avoid processing such styles in the first place.
Modified: trunk/MgDev/Common/Stylization/SE_LineRenderer.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_LineRenderer.cpp 2010-09-16 13:51:48 UTC (rev 5133)
+++ trunk/MgDev/Common/Stylization/SE_LineRenderer.cpp 2010-09-16 20:40:44 UTC (rev 5134)
@@ -214,10 +214,13 @@
{
_ASSERT(style->repeat > 0.0);
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = style->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_BufferPool* lbp = GetBufferPool();
- SE_RenderPrimitiveList& rs = style->symbol;
-
RS_FontEngine* fe = GetRSFontEngine();
double px2su = GetScreenUnitsPerPixel();
@@ -255,11 +258,11 @@
// in the symbol. We need this because straight lines become curved when
// the warping is applied.
int maxChoppedSize = 0;
- choppedBuffers = (LineBuffer**)alloca(rs.size() * sizeof(LineBuffer*));
- memset(choppedBuffers, 0, rs.size() * sizeof(LineBuffer*));
- for (unsigned cur_prim=0; cur_prim<rs.size(); ++cur_prim)
+ choppedBuffers = (LineBuffer**)alloca(prims.size() * sizeof(LineBuffer*));
+ memset(choppedBuffers, 0, prims.size() * sizeof(LineBuffer*));
+ for (unsigned cur_prim=0; cur_prim<prims.size(); ++cur_prim)
{
- SE_RenderPrimitive* primitive = rs[cur_prim];
+ SE_RenderPrimitive* primitive = prims[cur_prim];
if (primitive->type == SE_RenderPrimitive_Polygon || primitive->type == SE_RenderPrimitive_Polyline)
{
@@ -434,7 +437,7 @@
{
// We're not yet in danger of a corner (or the start/end of the distribution).
// Just put the pedal to the metal and draw an unwarped symbol.
- DrawSymbol(rs, xformStart, next_hotspot->angle_start);
+ DrawSymbol(prims, xformStart, next_hotspot->angle_start);
drawpos += repeat;
sym_minx = drawpos + styleBounds.minx;
@@ -448,9 +451,9 @@
double last_angleRad = 0.0;
// loop over the symbol's primitive elements - we will handle them one by one
- for (unsigned cur_prim=0; cur_prim<rs.size(); ++cur_prim)
+ for (unsigned cur_prim=0; cur_prim<prims.size(); ++cur_prim)
{
- SE_RenderPrimitive* primitive = rs[cur_prim];
+ SE_RenderPrimitive* primitive = prims[cur_prim];
// initialize our work buffer to the chopped line buffer
geom = *choppedBuffers[cur_prim];
@@ -986,7 +989,7 @@
// free the chopped line buffers
if (choppedBuffers)
{
- for (unsigned cur_prim=0; cur_prim<rs.size(); ++cur_prim)
+ for (unsigned cur_prim=0; cur_prim<prims.size(); ++cur_prim)
{
if (choppedBuffers[cur_prim] != NULL)
LineBufferPool::FreeLineBuffer(lbp, choppedBuffers[cur_prim]);
@@ -1863,6 +1866,11 @@
{
_ASSERT(style->repeat > 0.0);
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = style->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_Matrix symxf;
bool yUp = YPointsUp();
double px2su = GetScreenUnitsPerPixel();
@@ -2131,7 +2139,7 @@
// only draw symbols at the interior points
if (numDrawn > 0 && numDrawn < numSymbols-1)
- DrawSymbol(style->symbol, symxf, angleRad, style->addToExclusionRegion);
+ DrawSymbol(prims, symxf, angleRad, style->addToExclusionRegion);
// handle the centerline path at the group's end - only
// need to do this if we have at least one interior symbol
@@ -2215,6 +2223,11 @@
{
_ASSERT(style->repeat > 0.0);
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = style->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_Matrix symxf;
bool yUp = YPointsUp();
double px2su = GetScreenUnitsPerPixel();
@@ -2439,7 +2452,7 @@
if (style->drawLast)
AddLabel(geometry, style, symxf, angleRad);
else
- DrawSymbol(style->symbol, symxf, angleRad, style->addToExclusionRegion);
+ DrawSymbol(prims, symxf, angleRad, style->addToExclusionRegion);
}
++numDrawn;
@@ -2474,6 +2487,11 @@
// Distributes feature labels along a polyline.
void SE_Renderer::ProcessLineLabels(LineBuffer* geometry, SE_RenderLineStyle* style)
{
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = style->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_Matrix symxf;
bool yUp = YPointsUp();
Modified: trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp
===================================================================
--- trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp 2010-09-16 13:51:48 UTC (rev 5133)
+++ trunk/MgDev/Common/Stylization/SE_PositioningAlgorithms.cpp 2010-09-16 20:40:44 UTC (rev 5134)
@@ -77,6 +77,11 @@
void SE_PositioningAlgorithms::Default(SE_ApplyContext* applyCtx,
SE_RenderStyle* rstyle)
{
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = rstyle->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_Renderer* se_renderer = applyCtx->renderer;
LineBuffer* geometry = applyCtx->geometry;
SE_Matrix& xform = *applyCtx->xform;
@@ -184,12 +189,13 @@
if (rstyle->type != SE_RenderStyle_Point)
return;
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = rstyle->symbol;
+ if (prims.size() == 0)
+ return;
+
SE_RenderPointStyle* rpstyle = (SE_RenderPointStyle*)rstyle;
- // the point style needs to contain at least one graphic element
- if (rpstyle->symbol.size() == 0)
- return;
-
// get actual feature point and transform to screen space
// TODO: in the case of a multi-point feature we get the average of all the points;
// generating candidate labels around this point doesn't make a whole lot of
@@ -327,9 +333,9 @@
// check if the incoming point style contains just a single text element
bool foundSingleText = false;
- if (rpstyle->symbol.size() == 1)
+ if (prims.size() == 1)
{
- if (rpstyle->symbol[0]->type == SE_RenderPrimitive_Text)
+ if (prims[0]->type == SE_RenderPrimitive_Text)
foundSingleText = true;
}
@@ -465,12 +471,17 @@
if (rstyle->type == SE_RenderStyle_Area)
return;
+ // the style needs to contain at least one primitive
+ SE_RenderPrimitiveList& prims = rstyle->symbol;
+ if (prims.size() == 0)
+ return;
+
// If the symbol contains just a single text element then add the
// text as a regular path label (non-symbol). Use 0.5 as the
// default value for the scale limit.
- if (rstyle->symbol.size() == 1 && rstyle->symbol[0]->type == SE_RenderPrimitive_Text)
+ if (prims.size() == 1 && prims[0]->type == SE_RenderPrimitive_Text)
{
- SE_RenderText* rt = (SE_RenderText*)rstyle->symbol[0];
+ SE_RenderText* rt = (SE_RenderText*)prims[0];
RS_LabelInfo info(0.0, 0.0, 0.0, 0.0, RS_Units_Device, rt->tdef);
RS_OverpostType overpostType = rstyle->checkExclusionRegion? RS_OverpostType_AllFit : RS_OverpostType_All;
More information about the mapguide-commits
mailing list