[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58231] trunk/blender/source/blender/ editors/space_image/image_ops.c: fix [#36135] File name of previously saved render result no longer remembered
Campbell Barton
ideasman42 at gmail.com
Sun Jul 14 11:57:03 CEST 2013
Revision: 58231
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58231
Author: campbellbarton
Date: 2013-07-14 09:57:03 +0000 (Sun, 14 Jul 2013)
Log Message:
-----------
fix [#36135] File name of previously saved render result no longer remembered
in fact the problem was caused by own previous fix/improvement for a different case, now this works as follows...
- render uses last-saved name, falls back to 'untitled' in blend file path.
- non render uses id-name always, saves into dir of last-saved image, fall back to blend file path.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_image/image_ops.c
Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c 2013-07-14 08:13:02 UTC (rev 58230)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c 2013-07-14 09:57:03 UTC (rev 58231)
@@ -1204,7 +1204,8 @@
}
}
-static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene, const short guess_path)
+static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, Scene *scene,
+ const bool guess_path, const bool save_as_render)
{
void *lock;
ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock);
@@ -1253,8 +1254,20 @@
/* check for empty path */
if (guess_path && simopts->filepath[0] == 0) {
- BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2);
- BLI_path_abs(simopts->filepath, STREQ(G.ima, "//") ? G.main->name : G.ima);
+ const bool is_prev_save = !STREQ(G.ima, "//");
+ if (save_as_render) {
+ if (is_prev_save) {
+ BLI_strncpy(simopts->filepath, G.ima, sizeof(simopts->filepath));
+ }
+ else {
+ BLI_strncpy(simopts->filepath, "//untitled", sizeof(simopts->filepath));
+ BLI_path_abs(simopts->filepath, G.main->name);
+ }
+ }
+ else {
+ BLI_snprintf(simopts->filepath, sizeof(simopts->filepath), "//%s", ima->id.name + 2);
+ BLI_path_abs(simopts->filepath, is_prev_save ? G.ima : G.main->name);
+ }
}
/* color management */
@@ -1425,7 +1438,7 @@
/* just in case to initialize values,
* these should be set on invoke or by the caller. */
- save_image_options_init(&simopts, sima, CTX_data_scene(C), 0);
+ save_image_options_init(&simopts, sima, CTX_data_scene(C), false, false);
save_image_options_from_op(&simopts, op);
@@ -1448,13 +1461,14 @@
Image *ima = ED_space_image(sima);
Scene *scene = CTX_data_scene(C);
SaveImageOptions simopts;
+ const bool save_as_render = ((ima->source == IMA_SRC_VIEWER) || (ima->flag & IMA_VIEW_AS_RENDER));
if (RNA_struct_property_is_set(op->ptr, "filepath"))
return image_save_as_exec(C, op);
save_image_options_defaults(&simopts);
- if (save_image_options_init(&simopts, sima, scene, TRUE) == 0)
+ if (save_image_options_init(&simopts, sima, scene, true, save_as_render) == 0)
return OPERATOR_CANCELLED;
save_image_options_to_op(&simopts, op);
@@ -1463,10 +1477,7 @@
RNA_boolean_set(op->ptr, "copy", TRUE);
}
- if (ima->source == IMA_SRC_VIEWER || (ima->flag & IMA_VIEW_AS_RENDER))
- RNA_boolean_set(op->ptr, "save_as_render", TRUE);
- else
- RNA_boolean_set(op->ptr, "save_as_render", FALSE);
+ RNA_boolean_set(op->ptr, "save_as_render", save_as_render);
op->customdata = MEM_mallocN(sizeof(simopts.im_format), __func__);
memcpy(op->customdata, &simopts.im_format, sizeof(simopts.im_format));
@@ -1565,7 +1576,7 @@
SaveImageOptions simopts;
save_image_options_defaults(&simopts);
- if (save_image_options_init(&simopts, sima, scene, FALSE) == 0)
+ if (save_image_options_init(&simopts, sima, scene, false, false) == 0)
return OPERATOR_CANCELLED;
save_image_options_from_op(&simopts, op);
More information about the Bf-blender-cvs
mailing list