From 18baf4d4fe523d84ad741d7fde0f10a58d47587b Mon Sep 17 00:00:00 2001 From: dooglus Date: Wed, 24 Oct 2007 01:14:08 +0000 Subject: [PATCH] Fix 1818856: External application render targets seem to be broken. We can't use popen(command, "wb") on Linux. git-svn-id: http://svn.voria.com/code@958 1f10aa63-cdf2-0310-b900-c93c546f37ac --- ETL/trunk/ETL/_stringf.h | 6 ++++++ synfig-core/trunk/src/modules/mod_bmp/trgt_bmp.cpp | 4 ++-- synfig-core/trunk/src/modules/mod_dv/trgt_dv.cpp | 2 +- synfig-core/trunk/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp | 2 +- synfig-core/trunk/src/modules/mod_gif/trgt_gif.cpp | 2 +- synfig-core/trunk/src/modules/mod_imagemagick/trgt_imagemagick.cpp | 2 +- synfig-core/trunk/src/modules/mod_jpeg/trgt_jpeg.cpp | 4 ++-- synfig-core/trunk/src/modules/mod_mng/trgt_mng.cpp | 2 +- synfig-core/trunk/src/modules/mod_png/trgt_png.cpp | 4 ++-- synfig-core/trunk/src/modules/mod_ppm/trgt_ppm.cpp | 4 ++-- synfig-core/trunk/src/modules/mod_yuv420p/trgt_yuv.cpp | 2 +- 11 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ETL/trunk/ETL/_stringf.h b/ETL/trunk/ETL/_stringf.h index 8173214..aaa87fd 100644 --- a/ETL/trunk/ETL/_stringf.h +++ b/ETL/trunk/ETL/_stringf.h @@ -40,6 +40,12 @@ #define ETL_STRPRINTF_MAX_LENGTH (800) #endif +#ifdef WIN32 +#define POPEN_BINARY_WRITE_TYPE "wb" +#else +#define POPEN_BINARY_WRITE_TYPE "w" +#endif + /* === T Y P E D E F S ===================================================== */ _ETL_BEGIN_CDECLS diff --git a/synfig-core/trunk/src/modules/mod_bmp/trgt_bmp.cpp b/synfig-core/trunk/src/modules/mod_bmp/trgt_bmp.cpp index cb51db2..71a84a7 100644 --- a/synfig-core/trunk/src/modules/mod_bmp/trgt_bmp.cpp +++ b/synfig-core/trunk/src/modules/mod_bmp/trgt_bmp.cpp @@ -178,12 +178,12 @@ bmp::start_frame(synfig::ProgressCallback *callback) String newfilename(filename_sans_extension(filename) + etl::strprintf("%04d",imagecount) + filename_extension(filename)); - file=fopen(newfilename.c_str(),"wb"); + file=fopen(newfilename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(newfilename+_(" (animated)")); } else { - file=fopen(filename.c_str(),"wb"); + file=fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(filename); } diff --git a/synfig-core/trunk/src/modules/mod_dv/trgt_dv.cpp b/synfig-core/trunk/src/modules/mod_dv/trgt_dv.cpp index 720736c..18dc1cd 100644 --- a/synfig-core/trunk/src/modules/mod_dv/trgt_dv.cpp +++ b/synfig-core/trunk/src/modules/mod_dv/trgt_dv.cpp @@ -128,7 +128,7 @@ dv_trgt::init() command=strprintf("encodedv - > \"%s\"\n",filename.c_str()); // Open the pipe to encodedv - file=popen(command.c_str(),"wb"); + file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE); if(!file) { diff --git a/synfig-core/trunk/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp b/synfig-core/trunk/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp index 5585878..e41d1a5 100644 --- a/synfig-core/trunk/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp +++ b/synfig-core/trunk/src/modules/mod_ffmpeg/trgt_ffmpeg.cpp @@ -128,7 +128,7 @@ ffmpeg_trgt::init() command=strprintf("ffmpeg -f image2pipe -vcodec ppm -an -r %f -i pipe: -loop -hq -title \"%s\" -vcodec mpeg1video -y \"%s\"\n",desc.get_frame_rate(),get_canvas()->get_name().c_str(),filename.c_str()); - file=popen(command.c_str(),"wb"); + file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE); // etl::yield(); diff --git a/synfig-core/trunk/src/modules/mod_gif/trgt_gif.cpp b/synfig-core/trunk/src/modules/mod_gif/trgt_gif.cpp index 0801310..6a3502c 100644 --- a/synfig-core/trunk/src/modules/mod_gif/trgt_gif.cpp +++ b/synfig-core/trunk/src/modules/mod_gif/trgt_gif.cpp @@ -58,7 +58,7 @@ SYNFIG_TARGET_SET_CVS_ID(gif,"$Id$"); gif::gif(const char *filename_): filename(filename_), - file( (filename=="-")?stdout:fopen(filename_,"wb") ), + file( (filename=="-")?stdout:fopen(filename_,POPEN_BINARY_WRITE_TYPE) ), imagecount(0), lossy(true), diff --git a/synfig-core/trunk/src/modules/mod_imagemagick/trgt_imagemagick.cpp b/synfig-core/trunk/src/modules/mod_imagemagick/trgt_imagemagick.cpp index 7478001..aaf015f 100644 --- a/synfig-core/trunk/src/modules/mod_imagemagick/trgt_imagemagick.cpp +++ b/synfig-core/trunk/src/modules/mod_imagemagick/trgt_imagemagick.cpp @@ -125,7 +125,7 @@ imagemagick_trgt::start_frame(synfig::ProgressCallback *cb) else command=strprintf("convert -depth 8 -size %dx%d rgb:-[0] -density %dx%d \"%s\"\n",desc.get_w(),desc.get_h(),round_to_int(desc.get_x_res()/39.3700787402),round_to_int(desc.get_y_res()/39.3700787402),filename.c_str()); - file=popen(command.c_str(),"wb"); + file=popen(command.c_str(),POPEN_BINARY_WRITE_TYPE); if(!file) { diff --git a/synfig-core/trunk/src/modules/mod_jpeg/trgt_jpeg.cpp b/synfig-core/trunk/src/modules/mod_jpeg/trgt_jpeg.cpp index 013a99a..28994e1 100644 --- a/synfig-core/trunk/src/modules/mod_jpeg/trgt_jpeg.cpp +++ b/synfig-core/trunk/src/modules/mod_jpeg/trgt_jpeg.cpp @@ -112,12 +112,12 @@ jpeg_trgt::start_frame(synfig::ProgressCallback *callback) String newfilename(filename_sans_extension(filename) + etl::strprintf("%04d",imagecount) + filename_extension(filename)); - file=fopen(newfilename.c_str(),"wb"); + file=fopen(newfilename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(newfilename); } else { - file=fopen(filename.c_str(),"wb"); + file=fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(filename); } diff --git a/synfig-core/trunk/src/modules/mod_mng/trgt_mng.cpp b/synfig-core/trunk/src/modules/mod_mng/trgt_mng.cpp index d925846..01bebf4 100644 --- a/synfig-core/trunk/src/modules/mod_mng/trgt_mng.cpp +++ b/synfig-core/trunk/src/modules/mod_mng/trgt_mng.cpp @@ -148,7 +148,7 @@ mng_trgt::init(){ struct tm* gmt = gmtime(&t); w=desc.get_w(); h=desc.get_h(); //synfig::error("mng_trgt: init %d %d",w,h); - file = fopen(filename.c_str(), "wb"); + file = fopen(filename.c_str(), POPEN_BINARY_WRITE_TYPE); if( file == NULL ) goto cleanup_on_error; mng = mng_initialize((mng_ptr)file, mng_alloc_proc, mng_free_proc, MNG_NULL); if(mng == MNG_NULL) goto cleanup_on_error; diff --git a/synfig-core/trunk/src/modules/mod_png/trgt_png.cpp b/synfig-core/trunk/src/modules/mod_png/trgt_png.cpp index dcaa538..e2646be 100644 --- a/synfig-core/trunk/src/modules/mod_png/trgt_png.cpp +++ b/synfig-core/trunk/src/modules/mod_png/trgt_png.cpp @@ -143,12 +143,12 @@ png_trgt::start_frame(synfig::ProgressCallback *callback) String newfilename(filename_sans_extension(filename) + etl::strprintf("%04d",imagecount) + filename_extension(filename)); - file=fopen(newfilename.c_str(),"wb"); + file=fopen(newfilename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(newfilename); } else { - file=fopen(filename.c_str(),"wb"); + file=fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE); if(callback)callback->task(filename); } diff --git a/synfig-core/trunk/src/modules/mod_ppm/trgt_ppm.cpp b/synfig-core/trunk/src/modules/mod_ppm/trgt_ppm.cpp index effe64d..14dba1d 100644 --- a/synfig-core/trunk/src/modules/mod_ppm/trgt_ppm.cpp +++ b/synfig-core/trunk/src/modules/mod_ppm/trgt_ppm.cpp @@ -106,12 +106,12 @@ ppm::start_frame(synfig::ProgressCallback *callback) String newfilename(filename_sans_extension(filename) + etl::strprintf("%04d",imagecount) + filename_extension(filename)); - file=SmartFILE(fopen(newfilename.c_str(),"wb")); + file=SmartFILE(fopen(newfilename.c_str(),POPEN_BINARY_WRITE_TYPE)); if(callback)callback->task(newfilename); } else { - file=SmartFILE(fopen(filename.c_str(),"wb")); + file=SmartFILE(fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE)); if(callback)callback->task(filename); } diff --git a/synfig-core/trunk/src/modules/mod_yuv420p/trgt_yuv.cpp b/synfig-core/trunk/src/modules/mod_yuv420p/trgt_yuv.cpp index 3f65801..81482c9 100644 --- a/synfig-core/trunk/src/modules/mod_yuv420p/trgt_yuv.cpp +++ b/synfig-core/trunk/src/modules/mod_yuv420p/trgt_yuv.cpp @@ -64,7 +64,7 @@ SYNFIG_TARGET_SET_CVS_ID(yuv,"$Id$"); yuv::yuv(const char *FILENAME): filename(FILENAME), - file( (filename=="-")?stdout:fopen(filename.c_str(),"wb") ), + file( (filename=="-")?stdout:fopen(filename.c_str(),POPEN_BINARY_WRITE_TYPE) ), dithering(true) { // YUV420P doesn't have an alpha channel -- 2.7.4