[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32920] trunk/blender/source/blender/ editors/space_image/image_ops.c: fix [#24554] Blender does not remember name of last saved picture

Andrea Weikert elubie at gmx.net
Sun Nov 7 16:07:14 CET 2010


Revision: 32920
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32920
Author:   elubie
Date:     2010-11-07 16:07:14 +0100 (Sun, 07 Nov 2010)

Log Message:
-----------
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. 

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	2010-11-07 14:57:24 UTC (rev 32919)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2010-11-07 15:07:14 UTC (rev 32920)
@@ -875,9 +875,16 @@
 			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 @@
 			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 @@
 	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 @@
 		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);
 		





More information about the Bf-blender-cvs mailing list