[mapserver-commits] r11449 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Sat Apr 2 18:19:06 EDT 2011
Author: dmorissette
Date: 2011-04-02 15:19:06 -0700 (Sat, 02 Apr 2011)
New Revision: 11449
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/maputil.c
Log:
Improved error reporting in msSaveImage() (#3733)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-04-02 20:11:21 UTC (rev 11448)
+++ trunk/mapserver/HISTORY.TXT 2011-04-02 22:19:06 UTC (rev 11449)
@@ -15,6 +15,8 @@
Current Version (SVN trunk):
----------------------------
+- Improved error reporting in msSaveImage() (#3733)
+
- configure: look for libxslt.so under lib64 as well
- added missing ';' before charset in WFS DEscribeFeatureType header (#3793)
Modified: trunk/mapserver/maputil.c
===================================================================
--- trunk/mapserver/maputil.c 2011-04-02 20:11:21 UTC (rev 11448)
+++ trunk/mapserver/maputil.c 2011-04-02 22:19:06 UTC (rev 11449)
@@ -731,12 +731,13 @@
int msSaveImage(mapObj *map, imageObj *img, char *filename)
{
- int nReturnVal = -1;
+ int nReturnVal = MS_FAILURE;
char szPath[MS_MAXPATHLEN];
struct mstimeval starttime, endtime;
- if(map && map->debug >= MS_DEBUGLEVEL_TUNING)
+ if(map && map->debug >= MS_DEBUGLEVEL_TUNING) {
msGettimeofday(&starttime, NULL);
+ }
if (img)
{
@@ -753,33 +754,38 @@
#endif
if (MS_RENDERER_PLUGIN(img->format)) {
rendererVTableObj *renderer = img->format->vtable;
- FILE *stream;
- int ret;
+ FILE *stream = NULL;
if(filename) {
if(map)
stream = fopen(msBuildPath(szPath, map->mappath, filename),"wb");
else
stream = fopen(filename,"wb");
+
+ if(!stream) {
+ msSetError(MS_IOERR,
+ "Failed to create output file (%s).",
+ "msSaveImage()", (map?szPath:filename) );
+ return MS_FAILURE;
+ }
+
} else {
if ( msIO_needBinaryStdout() == MS_FAILURE )
return MS_FAILURE;
stream = stdout;
}
- if(!stream)
- return MS_FAILURE;
- if(renderer->supports_pixel_buffer) {
+
+ if(renderer->supports_pixel_buffer) {
rasterBufferObj data;
if(renderer->getRasterBufferHandle(img,&data) != MS_SUCCESS)
return MS_FAILURE;
- ret = msSaveRasterBuffer(&data,stream,img->format );
+ nReturnVal = msSaveRasterBuffer(&data,stream,img->format );
} else {
- ret = renderer->saveImage(img, stream, img->format);
+ nReturnVal = renderer->saveImage(img, stream, img->format);
}
if( stream != stdout )
fclose(stream);
- return ret;
}
else if( MS_DRIVER_IMAGEMAP(img->format) )
nReturnVal = msSaveImageIM(img, filename, img->format);
@@ -790,7 +796,8 @@
if(map && map->debug >= MS_DEBUGLEVEL_TUNING) {
msGettimeofday(&endtime, NULL);
- msDebug("msSaveImage() total time: %.3fs\n",
+ msDebug("msSaveImage(%s) total time: %.3fs\n",
+ (filename ? filename : "stdout"),
(endtime.tv_sec+endtime.tv_usec/1.0e6)-
(starttime.tv_sec+starttime.tv_usec/1.0e6) );
}
More information about the mapserver-commits
mailing list