[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36737] trunk/blender/source/blender: - check paths are not empty strings before making blend file paths absolute or relative .

Campbell Barton ideasman42 at gmail.com
Wed May 18 08:48:52 CEST 2011


Revision: 36737
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36737
Author:   campbellbarton
Date:     2011-05-18 06:48:52 +0000 (Wed, 18 May 2011)
Log Message:
-----------
- check paths are not empty strings before making blend file paths absolute or relative.
- when saving blend file with 'Remap Relative' enabled, don't try make paths absolute if the internal filename is invalid.
- use case insensitive path comparison on windows when checking if path remapping is needed & for comparing next/prev dirs in the file selector.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/bpath.c
    trunk/blender/source/blender/blenloader/intern/writefile.c
    trunk/blender/source/blender/editors/space_file/filelist.c

Modified: trunk/blender/source/blender/blenlib/intern/bpath.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/bpath.c	2011-05-18 06:27:32 UTC (rev 36736)
+++ trunk/blender/source/blender/blenlib/intern/bpath.c	2011-05-18 06:48:52 UTC (rev 36737)
@@ -699,7 +699,12 @@
 	
 	/* be sure there is low chance of the path being too short */
 	char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
-	
+
+	if(basedir[0] == '\0') {
+		printf("makeFilesRelative: basedir='', this is a bug\n");
+		return;
+	}
+
 	BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
 	while (!BLI_bpathIterator_isDone(bpi)) {
 		BLI_bpathIterator_getPath(bpi, filepath);
@@ -751,7 +756,10 @@
 	/* be sure there is low chance of the path being too short */
 	char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
 
-	BLI_assert(basedir[0] != '\0');
+	if(basedir[0] == '\0') {
+		printf("makeFilesAbsolute: basedir='', this is a bug\n");
+		return;
+	}
 
 	BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
 	while (!BLI_bpathIterator_isDone(bpi)) {

Modified: trunk/blender/source/blender/blenloader/intern/writefile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/writefile.c	2011-05-18 06:27:32 UTC (rev 36736)
+++ trunk/blender/source/blender/blenloader/intern/writefile.c	2011-05-18 06:48:52 UTC (rev 36737)
@@ -2547,10 +2547,18 @@
 		BLI_cleanup_dir(mainvar->name, dir1);
 		BLI_cleanup_dir(mainvar->name, dir2);
 
-		if(strcmp(dir1, dir2)==0)
+		if(BLI_path_cmp(dir1, dir2)==0) {
 			write_flags &= ~G_FILE_RELATIVE_REMAP;
-		else
-			makeFilesAbsolute(mainvar, G.main->name, NULL);
+		}
+		else {
+			if(G.relbase_valid) {
+				/* blend may not have been saved before. Tn this case
+				 * we should not have any relative paths, but if there
+				 * is somehow, an invalid or empty G.main->name it will
+				 * print an error, dont try make the absolute in this case. */
+				makeFilesAbsolute(mainvar, G.main->name, NULL);
+			}
+		}
 	}
 
 	BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);

Modified: trunk/blender/source/blender/editors/space_file/filelist.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filelist.c	2011-05-18 06:27:32 UTC (rev 36736)
+++ trunk/blender/source/blender/editors/space_file/filelist.c	2011-05-18 06:48:52 UTC (rev 36737)
@@ -433,7 +433,7 @@
 
 	// check if already exists
 	if(previous_folder && previous_folder->foldername){
-		if(! strcmp(previous_folder->foldername, dir)){
+		if(BLI_path_cmp(previous_folder->foldername, dir)==0){
 			return;
 		}
 	}




More information about the Bf-blender-cvs mailing list