Permalink
Browse files

Fix crash in drawQuery for layers with labelitem (#5281)

  • Loading branch information...
szekerest committed May 19, 2016
1 parent 8771b59 commit 5870da474f9d834e734e7a4fe2e49ba89d5165ab
Showing with 8 additions and 5 deletions.
  1. +2 −2 mapdraw.c
  2. +5 −2 maplabel.c
  3. +1 −1 mapserver.h
View
@@ -1568,7 +1568,7 @@ int pointLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer, shapeObj
}
if(MS_DRAW_LABELS(drawmode)) {
if (layer->labelcache) {
- if (msAddLabelGroup(map, image, layer->index, c, shape, point, -1) != MS_SUCCESS) return (MS_FAILURE);
+ if (msAddLabelGroup(map, image, layer, c, shape, point, -1) != MS_SUCCESS) return (MS_FAILURE);
} else {
for (l = 0; l < layer->class[c]->numlabels; l++)
if(msGetLabelStatus(map,layer,shape,layer->class[c]->labels[l]) == MS_ON) {
@@ -1765,7 +1765,7 @@ int polygonLayerDrawShape(mapObj *map, imageObj *image, layerObj *layer,
for (i = 0; i < layer->class[c]->numlabels; i++)
if (layer->class[c]->labels[i]->angle != 0) layer->class[c]->labels[i]->angle -= map->gt.rotation_angle; /* TODO: is this correct ??? */
if (layer->labelcache) {
- if (msAddLabelGroup(map, image, layer->index, c, anno_shape, &annopnt,
+ if (msAddLabelGroup(map, image, layer, c, anno_shape, &annopnt,
MS_MIN(shape->bounds.maxx - shape->bounds.minx, shape->bounds.maxy - shape->bounds.miny)) != MS_SUCCESS) {
return MS_FAILURE;
}
View
@@ -273,7 +273,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
ts->rotation = l->angle * MS_DEG_TO_RAD;
}
-int msAddLabelGroup(mapObj *map, imageObj *image, int layerindex, int classindex, shapeObj *shape, pointObj *point, double featuresize)
+int msAddLabelGroup(mapObj *map, imageObj *image, layerObj* layer, int classindex, shapeObj *shape, pointObj *point, double featuresize)
{
int l,s, priority;
labelCacheSlotObj *cacheslot;
@@ -283,8 +283,11 @@ int msAddLabelGroup(mapObj *map, imageObj *image, int layerindex, int classindex
classObj *classPtr=NULL;
int numtextsymbols = 0;
textSymbolObj **textsymbols, *ts;
+ int layerindex = layer->index;
- layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */
+ // We cannot use GET_LAYER here because in drawQuery the drawing may happen
+ // on a temp layer only.
+ layerPtr = layer;
classPtr = GET_LAYER(map, layerindex)->class[classindex];
if(classPtr->numlabels == 0) return MS_SUCCESS; /* not an error just nothing to do */
View
@@ -2308,7 +2308,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
MS_DLL_EXPORT int WARN_UNUSED msGetStringSize(mapObj *map, labelObj *label, int size, char *string, rectObj *r);
MS_DLL_EXPORT int WARN_UNUSED msAddLabel(mapObj *map, imageObj *image, labelObj *label, int layerindex, int classindex, shapeObj *shape, pointObj *point, double featuresize, textSymbolObj *ts);
- MS_DLL_EXPORT int WARN_UNUSED msAddLabelGroup(mapObj *map, imageObj *image, int layerindex, int classindex, shapeObj *shape, pointObj *point, double featuresize);
+ MS_DLL_EXPORT int WARN_UNUSED msAddLabelGroup(mapObj *map, imageObj *image, layerObj *layer, int classindex, shapeObj *shape, pointObj *point, double featuresize);
MS_DLL_EXPORT void insertRenderedLabelMember(mapObj *map, labelCacheMemberObj *cachePtr);
MS_DLL_EXPORT int msTestLabelCacheCollisions(mapObj *map, labelCacheMemberObj *cachePtr, label_bounds *lb, int current_priority, int current_label);
MS_DLL_EXPORT int msTestLabelCacheLeaderCollision(mapObj *map, pointObj *lp1, pointObj *lp2);

0 comments on commit 5870da4

Please sign in to comment.