Permalink
Browse files

add missing map reference to image

When msCreateLegendIcon and msDrawLegendIcon are called from mapscript directly, the image does not have a map assigned. This causes a crash when the legend references a symbol as in the maprendering.c getTile function and tries to get the font from the image's map fontset reference.
  • Loading branch information...
zidge authored and tbonfort committed Feb 26, 2014
1 parent 59019b6 commit 814286deddf85f4c9829619c2af617fc862cb02b
Showing with 4 additions and 1 deletion.
  1. +4 −1 maplegend.c
View
@@ -71,6 +71,7 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
image_draw = msImageCreate(image->width, image->height,
altFormat, image->imagepath, image->imageurl, map->resolution, map->defresolution, &map->imagecolor);
+ image_draw->map = map;
renderer = MS_IMAGE_RENDERER(image_draw);
} else {
renderer = MS_IMAGE_RENDERER(image_draw);
@@ -83,7 +84,8 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
"msDrawLegendIcon()");
return (MS_FAILURE);
}
- /* set opacity to full, as the renderer should be rendering a fully opaque image */
+ image_draw->map = map;
+ /* set opacity to full, as the renderer should be rendering a fully opaque image */
lp->opacity=100;
}
}
@@ -406,6 +408,7 @@ imageObj *msCreateLegendIcon(mapObj* map, layerObj* lp, classObj* class, int wid
msSetError(MS_IMGERR, "Unable to initialize image.","msCreateLegendIcon()");
return(NULL);
}
+ image->map = map;
/* Call drawLegendIcon with destination (0, 0) */
/* Return an empty image if lp==NULL || class=NULL */

0 comments on commit 814286d

Please sign in to comment.