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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-30 15:39:42 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-30 15:43:11 +0400
commit7829ef0051a16c1af88f72d99c329f5c75dd3eea (patch)
tree10513154ed31554c44286ebbb653edb64656b0a5 /source
parent3803c646d8e8277d4d51473b03ac3153646a3493 (diff)
Report when saving images and text
also fix bug where text saving would strip last newline
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_image/image_ops.c24
-rw-r--r--source/blender/editors/space_text/text_ops.c12
2 files changed, 20 insertions, 16 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 0a6f86a1642..07d01f45bf0 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1449,13 +1449,16 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
RNA_string_set(op->ptr, "filepath", simopts->filepath);
}
-/* assumes name is FILE_MAX */
-/* ima->name and ibuf->name should end up the same */
-static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, int do_newpath)
+/**
+ * \return success.
+ * \note ``ima->name`` and ``ibuf->name`` should end up the same.
+ */
+static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveImageOptions *simopts, bool do_newpath)
{
Image *ima = ED_space_image(sima);
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ bool ok = false;
if (ibuf) {
ImBuf *colormanaged_ibuf;
@@ -1464,7 +1467,6 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
const bool save_copy = (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
const bool save_as_render = (RNA_struct_find_property(op->ptr, "save_as_render") && RNA_boolean_get(op->ptr, "save_as_render"));
ImageFormatData *imf = &simopts->im_format;
- bool ok = false;
/* old global to ensure a 2nd save goes to same dir */
BLI_strncpy(G.ima, simopts->filepath, sizeof(G.ima));
@@ -1494,8 +1496,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
Scene *scene = CTX_data_scene(C);
RenderResult *rr = BKE_image_acquire_renderresult(scene, ima);
if (rr) {
- RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.exr_codec);
- ok = true;
+ ok = RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.exr_codec);
}
else {
BKE_report(op->reports, RPT_ERROR, "Did not write, no Multilayer Image");
@@ -1503,9 +1504,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
BKE_image_release_renderresult(scene, ima);
}
else {
- if (BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy)) {
- ok = true;
- }
+ ok = BKE_imbuf_write_as(colormanaged_ibuf, simopts->filepath, &simopts->im_format, save_copy);
}
if (ok) {
@@ -1568,6 +1567,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
}
ED_space_image_release_buffer(sima, ibuf, lock);
+
+ return ok;
}
static void image_save_as_free(wmOperator *op)
@@ -1731,7 +1732,10 @@ static int image_save_exec(bContext *C, wmOperator *op)
save_image_options_from_op(&simopts, op);
if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) {
- save_image_doit(C, sima, op, &simopts, false);
+ if (save_image_doit(C, sima, op, &simopts, false)) {
+ /* report since this can be called from key-shortcuts */
+ BKE_reportf(op->reports, RPT_INFO, "Saved Image '%s'", simopts.filepath);
+ }
}
else {
BKE_reportf(op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", simopts.filepath);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 4835ef711e9..7b4481cfc7f 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -472,18 +472,18 @@ static void txt_write_file(Text *text, ReportList *reports)
return;
}
- tmp = text->lines.first;
- while (tmp) {
- if (tmp->next) fprintf(fp, "%s\n", tmp->line);
- else fprintf(fp, "%s", tmp->line);
-
- tmp = tmp->next;
+ for (tmp = text->lines.first; tmp; tmp = tmp->next) {
+ fputs(tmp->line, fp);
+ fputc('\n', fp);
}
fclose(fp);
if (BLI_stat(filepath, &st) == 0) {
text->mtime = st.st_mtime;
+
+ /* report since this can be called from key-shortcuts */
+ BKE_reportf(reports, RPT_INFO, "Saved Text '%s'", filepath);
}
else {
text->mtime = 0;