- 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.
This commit is contained in:
@@ -700,6 +700,11 @@ void makeFilesRelative(Main *bmain, const char *basedir, ReportList *reports) {
|
|||||||
/* be sure there is low chance of the path being too short */
|
/* be sure there is low chance of the path being too short */
|
||||||
char filepath_relative[(FILE_MAXDIR * 2) + FILE_MAXFILE];
|
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);
|
BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
|
||||||
while (!BLI_bpathIterator_isDone(bpi)) {
|
while (!BLI_bpathIterator_isDone(bpi)) {
|
||||||
BLI_bpathIterator_getPath(bpi, filepath);
|
BLI_bpathIterator_getPath(bpi, filepath);
|
||||||
@@ -751,7 +756,10 @@ void makeFilesAbsolute(Main *bmain, const char *basedir, ReportList *reports)
|
|||||||
/* be sure there is low chance of the path being too short */
|
/* be sure there is low chance of the path being too short */
|
||||||
char filepath_absolute[(FILE_MAXDIR * 2) + FILE_MAXFILE];
|
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);
|
BLI_bpathIterator_init(&bpi, bmain, basedir, 0);
|
||||||
while (!BLI_bpathIterator_isDone(bpi)) {
|
while (!BLI_bpathIterator_isDone(bpi)) {
|
||||||
|
|||||||
@@ -2547,11 +2547,19 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL
|
|||||||
BLI_cleanup_dir(mainvar->name, dir1);
|
BLI_cleanup_dir(mainvar->name, dir1);
|
||||||
BLI_cleanup_dir(mainvar->name, dir2);
|
BLI_cleanup_dir(mainvar->name, dir2);
|
||||||
|
|
||||||
if(strcmp(dir1, dir2)==0)
|
if(BLI_path_cmp(dir1, dir2)==0) {
|
||||||
write_flags &= ~G_FILE_RELATIVE_REMAP;
|
write_flags &= ~G_FILE_RELATIVE_REMAP;
|
||||||
else
|
}
|
||||||
|
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);
|
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);
|
BLI_make_file_string(G.main->name, userfilename, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_STARTUP_FILE);
|
||||||
write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
|
write_user_block= (BLI_path_cmp(filepath, userfilename) == 0);
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir)
|
|||||||
|
|
||||||
// check if already exists
|
// check if already exists
|
||||||
if(previous_folder && previous_folder->foldername){
|
if(previous_folder && previous_folder->foldername){
|
||||||
if(! strcmp(previous_folder->foldername, dir)){
|
if(BLI_path_cmp(previous_folder->foldername, dir)==0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user