Skip to content

Commit

Permalink
remove broken GD code in mapscript
Browse files Browse the repository at this point in the history
brought up by #4274
  • Loading branch information
tbonfort committed Apr 10, 2012
1 parent 22f56c9 commit 8d94e4a
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 9 deletions.
12 changes: 4 additions & 8 deletions mapio.c
Expand Up @@ -553,11 +553,7 @@ typedef struct {
gdIOCtx gd_io_ctx;
#endif
msIOContext *ms_io_ctx;
} msIO_gdIOCtx;

#ifndef USE_GD
#define gdIOCtx void
#endif
} msIO_IOCtx;


#ifdef USE_GD
Expand Down Expand Up @@ -600,6 +596,7 @@ static int msIO_gd_putBuf( gdIOCtx *cbData, const void *data, int byteCount )
/* longer needed. */
/************************************************************************/

#ifdef USE_GD
gdIOCtx *msIO_getGDIOCtx( FILE *fp )

{
Expand All @@ -609,15 +606,14 @@ gdIOCtx *msIO_getGDIOCtx( FILE *fp )
if( context == NULL )
return NULL;

merged_context = (msIO_gdIOCtx *) calloc(1,sizeof(msIO_gdIOCtx));
#ifdef USE_GD
merged_context = (msIO_IOCtx *) calloc(1,sizeof(msIO_IOCtx));
merged_context->gd_io_ctx.putC = msIO_gd_putC;
merged_context->gd_io_ctx.putBuf = msIO_gd_putBuf;
#endif
merged_context->ms_io_ctx = context;

return (gdIOCtx *) merged_context;
}
#endif

/* ==================================================================== */
/* ==================================================================== */
Expand Down
2 changes: 1 addition & 1 deletion mapscript/php/image.c
Expand Up @@ -328,7 +328,7 @@ PHP_METHOD(imageObj, saveImage)
php_write(iptr, size TSRMLS_CC);
status = MS_SUCCESS;
/* status = size; why should we return the size ?? */
gdFree(iptr);
msFree(iptr);
}

RETURN_LONG(status);
Expand Down
5 changes: 5 additions & 0 deletions mapscript/python/pyextend.i
Expand Up @@ -168,6 +168,7 @@ def fromstring(data, mappath=None):
imageObj(PyObject *arg1=Py_None, PyObject *arg2=Py_None,
PyObject *input_format=Py_None, PyObject *input_resolution=Py_None, PyObject *input_defresolution=Py_None)
{
#ifdef FORCE_BROKEN_GD_CODE
imageObj *image=NULL;
outputFormatObj *format=NULL;
int width;
Expand Down Expand Up @@ -318,6 +319,10 @@ def fromstring(data, mappath=None):
"imageObj()");
return NULL;
}
#else
msSetError(MS_IMGERR, "imageObj() is severely broken and should not be used","imageObj()");
return NULL;
#endif
}

/* ======================================================================
Expand Down
4 changes: 4 additions & 0 deletions mapscript/python/pygdioctx/pygdioctx.c
Expand Up @@ -47,6 +47,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************/

#ifdef USE_GD

#include "pygdioctx.h"

int PyFileIfaceObj_IOCtx_GetC(gdIOCtx *ctx)
Expand Down Expand Up @@ -161,3 +163,5 @@ imageObj *createImageObjFromPyFile(PyObject *file, const char *driver)
}
}

#endif

4 changes: 4 additions & 0 deletions mapscript/python/pygdioctx/pygdioctx.h
Expand Up @@ -47,6 +47,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ***************************************************************************/

#ifdef USE_GD

#include <Python.h>
#include <gd.h>
#include <gdfonts.h>
Expand Down Expand Up @@ -74,3 +76,5 @@ struct PyFileIfaceObj_gdIOCtx * alloc_PyFileIfaceObj_IOCtx(PyObject *fileIfaceOb
void free_PyFileIfaceObj_IOCtx(struct PyFileIfaceObj_gdIOCtx *pctx);
imageObj *createImageObjFromPyFile(PyObject *file, const char *driver);

#endif

6 changes: 6 additions & 0 deletions mapscript/swiginc/image.i
Expand Up @@ -143,6 +143,7 @@
Tcl_Obj *saveToString()
{

#ifdef FORCE_BROKEN_GD_CODE
unsigned char *imgbytes;
int size;
Tcl_Obj *imgstring;
Expand Down Expand Up @@ -210,6 +211,11 @@
gdFree(imgbytes);

return imgstring;
#else /* force_gd_broken_code */
msSetError(MS_MISCERR, "saveToString() is long deprecated and severley broken", "saveToString()", self->format->driver );
return(MS_FAILURE);
#endif

}
#endif

Expand Down
2 changes: 2 additions & 0 deletions mapserver.h
Expand Up @@ -2266,6 +2266,8 @@ MS_DLL_EXPORT imageObj *msImageLoadGD( const char *filename );
MS_DLL_EXPORT imageObj *msImageLoadGDCtx( gdIOCtx *ctx, const char *driver );
MS_DLL_EXPORT int msGDSetup();
MS_DLL_EXPORT void msGDCleanup(int signal);
#else
//#define gdIOCtx void*
#endif
MS_DLL_EXPORT void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image);
MS_DLL_EXPORT int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format);
Expand Down

0 comments on commit 8d94e4a

Please sign in to comment.