Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-01-11 04:32:29 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-01-11 04:32:29 +0300
commit961ac8eb85a6ede92c0d1bd062d2bdf264bbaef5 (patch)
treea7c28997d99792827db4004058ee6c5608a1b265 /source/blender/editors
parentf28d3955e9c848c32e340ec6696142ef124562d5 (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')
-rw-r--r--source/blender/editors/screen/screendump.c12
-rw-r--r--source/blender/editors/space_image/image_ops.c8
2 files changed, 15 insertions, 5 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))
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 1d11e7c6287..c35f5ae14c5 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1580,7 +1580,9 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
-static void save_image_post(wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy, const char *relbase, int relative, int do_newpath, const char *filepath)
+static void save_image_post(
+ wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy,
+ const char *relbase, int relative, int do_newpath, const char *filepath)
{
if (ok) {
if (!save_copy) {
@@ -1630,7 +1632,7 @@ static void save_image_post(wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int
}
}
else {
- BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", filepath);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
}
}
@@ -2151,7 +2153,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op)
BLI_path_abs(name, bmain->name);
if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) {
- BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", name);
+ BKE_reportf(op->reports, RPT_ERROR, "Could not write image: %s", strerror(errno));
break;
}