diff options
author | Andrea Weikert <elubie@gmx.net> | 2007-11-10 14:45:25 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2007-11-10 14:45:25 +0300 |
commit | 38d12b3c8de23acb7820b238523c9d28f83854d4 (patch) | |
tree | 9fae3ff09c225f376f11168209bb52b12d18aa54 /source/blender | |
parent | f02a746f56fb351ea92bbf82b8efbd3c1d6faa3e (diff) |
Bugfix #6797: Relative paths load problem on new file (fix included)
- brought back the check for a valid relative base when selecting.
- kept the check for when file is saved too and warning message is printed to console instead of popping up.
Also fixed BLI_split_filedir overwriting parameter passed as const char*
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenlib/intern/util.c | 32 | ||||
-rw-r--r-- | source/blender/src/editimasel.c | 19 | ||||
-rw-r--r-- | source/blender/src/filesel.c | 12 |
3 files changed, 39 insertions, 24 deletions
diff --git a/source/blender/blenlib/intern/util.c b/source/blender/blenlib/intern/util.c index 8e396eec09d..9e8fe80ae30 100644 --- a/source/blender/blenlib/intern/util.c +++ b/source/blender/blenlib/intern/util.c @@ -1275,26 +1275,28 @@ void BLI_split_dirfile(const char *string, char *dir, char *file) #ifdef WIN32 int sl; short is_relative = 0; + char path[FILE_MAX]; #endif dir[0]= 0; file[0]= 0; #ifdef WIN32 - BLI_char_switch(string, '/', '\\'); /* make sure we have a valid path format */ - sl = strlen(string); + BLI_strncpy(path, string, FILE_MAX); + BLI_char_switch(path, '/', '\\'); /* make sure we have a valid path format */ + sl = strlen(path); if (sl) { int len; - if (string[0] == '/' || string[0] == '\\') { - BLI_strncpy(dir, string, FILE_MAXDIR); - if (sl > 1 && string[0] == '\\' && string[1] == '\\') is_relative = 1; - } else if (sl > 2 && string[1] == ':' && string[2] == '\\') { - BLI_strncpy(dir, string, FILE_MAXDIR); + if (path[0] == '/' || path[0] == '\\') { + BLI_strncpy(dir, path, FILE_MAXDIR); + if (sl > 1 && path[0] == '\\' && path[1] == '\\') is_relative = 1; + } else if (sl > 2 && path[1] == ':' && path[2] == '\\') { + BLI_strncpy(dir, path, FILE_MAXDIR); } else { BLI_getwdN(dir); strcat(dir,"\\"); - strcat(dir,string); - BLI_strncpy(string,dir,FILE_MAXDIR+FILE_MAXFILE); + strcat(dir,path); + BLI_strncpy(path,dir,FILE_MAXDIR+FILE_MAXFILE); } // BLI_exist doesn't recognize a slashed dirname as a dir @@ -1315,15 +1317,15 @@ void BLI_split_dirfile(const char *string, char *dir, char *file) /* copy from end of string into file, to ensure filename itself isn't truncated if string is too long. (aphex) */ - len = FILE_MAXFILE - strlen(string); + len = FILE_MAXFILE - strlen(path); if (len < 0) - BLI_strncpy(file,string + abs(len),FILE_MAXFILE); + BLI_strncpy(file,path + abs(len),FILE_MAXFILE); else - BLI_strncpy(file,string,FILE_MAXFILE); + BLI_strncpy(file,path,FILE_MAXFILE); - if (strrchr(string,'\\')) { - BLI_strncpy(file,strrchr(string,'\\')+1,FILE_MAXFILE); + if (strrchr(path,'\\')) { + BLI_strncpy(file,strrchr(path,'\\')+1,FILE_MAXFILE); } if ( (a = strlen(dir)) ) { @@ -1334,7 +1336,7 @@ void BLI_split_dirfile(const char *string, char *dir, char *file) a = strlen(dir) - 1; while(a>0 && dir[a] != '\\') a--; dir[a + 1] = 0; - BLI_strncpy(file, string + strlen(dir),FILE_MAXFILE); + BLI_strncpy(file, path + strlen(dir),FILE_MAXFILE); } } diff --git a/source/blender/src/editimasel.c b/source/blender/src/editimasel.c index 8bf5b0f03cb..abc19b53671 100644 --- a/source/blender/src/editimasel.c +++ b/source/blender/src/editimasel.c @@ -546,15 +546,18 @@ static void imasel_execute(SpaceImaSel *simasel) strcat(name, simasel->file); if(simasel->flag & FILE_STRINGCODE) { - if (!G.relbase_valid) { - /* skip save */ - if(strncmp(simasel->title, "Save", 4)) { - okee("You have to save the .blend file before using relative paths! Using absolute path instead."); - simasel->flag &= ~FILE_STRINGCODE; - } - } - else { + /* still weak, but we don't want saving files to make relative paths */ + if(G.relbase_valid && strncmp(simasel->title, "Save", 4)) { BLI_makestringcode(G.sce, name); + } else { + /* if we don't have a valid relative base (.blend file hasn't been saved yet) + then we don't save the path as relative (for texture images, background image). + Warning message not shown when saving files (doesn't make sense there) + */ + if (strncmp(simasel->title, "Save", 4)) { + printf("Relative path setting has been ignored because .blend file hasn't been saved yet.\n"); + } + simasel->flag &= ~FILE_STRINGCODE; } } if(simasel->returnfunc) diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index ba5a04ddbce..10f234fcd21 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -1480,8 +1480,18 @@ static void filesel_execute(SpaceFile *sfile) if(sfile->flag & FILE_STRINGCODE) { /* still weak, but we don't want saving files to make relative paths */ - if(strncmp(sfile->title, "Save", 4)) + if(G.relbase_valid && strncmp(sfile->title, "Save", 4)) { BLI_makestringcode(G.sce, name); + } else { + /* if we don't have a valid relative base (.blend file hasn't been saved yet) + then we don't save the path as relative (for texture images, background image). + Warning message not shown when saving files (doesn't make sense there) + */ + if (strncmp(sfile->title, "Save", 4)) { + printf("Relative path setting has been ignored because .blend file hasn't been saved yet.\n"); + } + sfile->flag &= ~FILE_STRINGCODE; + } } if(sfile->returnfunc) sfile->returnfunc(name); |