[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31788] trunk/blender/source/blender/ editors/space_image/image_ops.c: bugfix [#23663] relative path dind work on linux

Campbell Barton ideasman42 at gmail.com
Mon Sep 6 15:29:00 CEST 2010


Revision: 31788
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31788
Author:   campbellbarton
Date:     2010-09-06 15:28:57 +0200 (Mon, 06 Sep 2010)

Log Message:
-----------
bugfix [#23663] relative path dind work on linux

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-09-06 12:54:54 UTC (rev 31787)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c	2010-09-06 13:28:57 UTC (rev 31788)
@@ -846,14 +846,14 @@
 
 /* assumes name is FILE_MAX */
 /* ima->name and ibuf->name should end up the same */
-static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOperator *op, char *path)
+static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOperator *op, char *path, int do_newpath)
 {
 	Image *ima= ED_space_image(sima);
 	void *lock;
 	ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock);
 
 	if (ibuf) {
-		int relative= RNA_boolean_get(op->ptr, "relative_path");
+		int relative= (RNA_struct_find_property(op->ptr, "relative_path") && RNA_boolean_get(op->ptr, "relative_path"));
 		int save_copy= (RNA_struct_find_property(op->ptr, "copy") && RNA_boolean_get(op->ptr, "copy"));
 
 		BLI_path_abs(path, G.sce);
@@ -879,8 +879,10 @@
 					BLI_path_rel(path, G.sce); /* only after saving */
 
 				if(!save_copy) {
-					BLI_strncpy(ima->name, path, sizeof(ima->name));
-					BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
+					if(do_newpath) {
+						BLI_strncpy(ima->name, path, sizeof(ima->name));
+						BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
+					}
 
 					/* should be function? nevertheless, saving only happens here */
 					for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next)
@@ -897,10 +899,11 @@
 				BLI_path_rel(path, G.sce); /* only after saving */
 
 			if(!save_copy) {
+				if(do_newpath) {
+					BLI_strncpy(ima->name, path, sizeof(ima->name));
+					BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
+				}
 
-				BLI_strncpy(ima->name, path, sizeof(ima->name));
-				BLI_strncpy(ibuf->name, path, sizeof(ibuf->name));
-
 				ibuf->userflags &= ~IB_BITMAPDIRTY;
 
 				/* change type? */
@@ -952,7 +955,7 @@
 	sima->imtypenr= RNA_enum_get(op->ptr, "file_type");
 	RNA_string_get(op->ptr, "filepath", str);
 
-	save_image_doit(C, sima, scene, op, str);
+	save_image_doit(C, sima, scene, op, str, TRUE);
 
 	return OPERATOR_FINISHED;
 }
@@ -1051,7 +1054,7 @@
 
 	/* if exists, saves over without fileselect */
 	
-	BLI_strncpy(name, ibuf->name, FILE_MAX);
+	BLI_strncpy(name, ima->name, FILE_MAX);
 	if(name[0]==0)
 		BLI_strncpy(name, G.ima, FILE_MAX);
 	else
@@ -1068,7 +1071,7 @@
 		BKE_image_release_renderresult(scene, ima);
 		ED_space_image_release_buffer(sima, lock);
 		
-		save_image_doit(C, sima, scene, op, name);
+		save_image_doit(C, sima, scene, op, name, FALSE);
 	}
 	else {
 		ED_space_image_release_buffer(sima, lock);





More information about the Bf-blender-cvs mailing list