diff options
author | Andrea Weikert <elubie@gmx.net> | 2010-11-07 18:07:14 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2010-11-07 18:07:14 +0300 |
commit | 034c95626055d4fa9f438e74bd062caae0356829 (patch) | |
tree | 39eb20ae35e928098ea8b9a1be259252015efa28 /source | |
parent | c7fab53ccb7fc4df46e9e4f0dc7583c3e4a6f8c3 (diff) |
fix [#24554] Blender does not remember name of last saved picture
* image name is now set when the file is actually saved if it is empty. Otherwise it is only changed if we're not saving a copy.
* If previous image name is empty, filename will be 'untitled.png' for png saving.
NOTE: if we saved a copy of 'render.png' as render1.png, the save image dialog will be re-opened with the image name that Blender has (render.png) rather than render1.png.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 50730e3b35e..f51576c613d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -875,9 +875,16 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera if(rr) { RE_WriteRenderResult(rr, path, scene->r.quality); + BLI_strncpy(G.ima, path, sizeof(G.ima)); + if(relative) BLI_path_rel(path, G.main->name); /* only after saving */ + if(ibuf->name[0]==0) { + BLI_strncpy(ibuf->name, path, sizeof(ibuf->name)); + BLI_strncpy(ima->name, path, sizeof(ima->name)); + } + if(!save_copy) { if(do_newpath) { BLI_strncpy(ima->name, path, sizeof(ima->name)); @@ -894,10 +901,17 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera BKE_image_release_renderresult(scene, ima); } else if (BKE_write_ibuf(scene, ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) { + + BLI_strncpy(G.ima, path, sizeof(G.ima)); if(relative) BLI_path_rel(path, G.main->name); /* only after saving */ + if(ibuf->name[0]==0) { + BLI_strncpy(ibuf->name, path, sizeof(ibuf->name)); + BLI_strncpy(ima->name, path, sizeof(ima->name)); + } + if(!save_copy) { if(do_newpath) { BLI_strncpy(ima->name, path, sizeof(ima->name)); @@ -978,6 +992,8 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) Image *ima = ED_space_image(sima); Scene *scene= CTX_data_scene(C); ImBuf *ibuf; + char filename[FILE_MAX]; + void *lock; if(!RNA_property_is_set(op->ptr, "relative_path")) @@ -1006,15 +1022,21 @@ static int save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) RNA_enum_set(op->ptr, "file_type", sima->imtypenr); if(ibuf->name[0]==0) - BLI_strncpy(ibuf->name, G.ima, FILE_MAX); - + if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) { + BLI_strncpy(filename, "//untitled", FILE_MAX); + } else { + BLI_strncpy(filename, G.ima, FILE_MAX); + } + else + BLI_strncpy(filename, ibuf->name, FILE_MAX); + /* enable save_copy by default for render results */ if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_property_is_set(op->ptr, "copy")) { RNA_boolean_set(op->ptr, "copy", TRUE); } // XXX note: we can give default menu enums to operator for this - image_filesel(C, op, ibuf->name); + image_filesel(C, op, filename); ED_space_image_release_buffer(sima, lock); |