diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-01-11 04:32:29 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-01-11 04:32:29 +0300 |
commit | 961ac8eb85a6ede92c0d1bd062d2bdf264bbaef5 (patch) | |
tree | a7c28997d99792827db4004058ee6c5608a1b265 /source/blender/editors/screen/screendump.c | |
parent | f28d3955e9c848c32e340ec6696142ef124562d5 (diff) |
Report errno string when writing files fails
Screenshot ignored errors, some render code printed 'Saved' without checking for failure.
note: errno is now cleared from IMB_saveiff so all callers don't need to.
Diffstat (limited to 'source/blender/editors/screen/screendump.c')
-rw-r--r-- | source/blender/editors/screen/screendump.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index a701fc9ccb7..a354d1145fe 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -30,6 +30,7 @@ #include <string.h> +#include <errno.h> #include "MEM_guardedalloc.h" @@ -177,6 +178,7 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop) static int screenshot_exec(bContext *C, wmOperator *op) { ScreenshotData *scd = op->customdata; + bool ok = false; if (scd == NULL) { /* when running exec directly */ @@ -204,14 +206,20 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } - BKE_imbuf_write(ibuf, path, &scd->im_format); + if (BKE_imbuf_write(ibuf, path, &scd->im_format)) { + ok = true; + } + else { + BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno)); + } IMB_freeImBuf(ibuf); } } screenshot_data_free(op); - return OPERATOR_FINISHED; + + return ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) |