From ffe630b452f4abb28c105fca2b8eb9fdb6e72370 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 20 Aug 2006 14:41:13 +0000 Subject: Fixes for: [ #4337 ] Cant refresh the C:\ [ #4710 ] Wrong paths in file selector under user prefs [ #4353 ] Using ^ char + click on Open/Load = Blender crash Details: Fixes for root paths like C:\ on Windows, where Blender still used '/'. Also contains fixes for relative paths: - no relative paths for the default dirs (forced to absolute) - message if using relative paths when .blend file hasn't been saved. Lastly also added '.' for refresh in root paths. Windows FindFirstFile/FindNextFile also return '.' and '..', but not in root paths like C:\ --- source/blender/src/filesel.c | 16 ++++++++++++++-- source/blender/src/headerbuttons.c | 18 ++++++++++++++++++ source/blender/src/usiblender.c | 6 +++++- 3 files changed, 37 insertions(+), 3 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index bc1bfba9161..da73aa33225 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -705,7 +705,9 @@ void parent(SpaceFile *sfile) if( (a = strlen(dir)) ) { if (dir[a-1] != '\\') strcat(dir,"\\"); } - else if(sfile->type!=FILE_MAIN) strcpy(dir,"\\"); + else if(sfile->type!=FILE_MAIN) { + get_default_root(dir); + } #else if( (a = strlen(dir)) ) { /* remove all '/' at the end */ while(dir[a-1] == '/') { @@ -1518,7 +1520,15 @@ static void filesel_execute(SpaceFile *sfile) BLI_strncpy(name, sfile->dir, sizeof(name)); strcat(name, sfile->file); - if(sfile->flag & FILE_STRINGCODE) BLI_makestringcode(G.sce, name); + if(sfile->flag & FILE_STRINGCODE) { + if (!G.relbase_valid) { + okee("You have to save the .blend file before using relative paths! Using absolute path instead."); + sfile->flag & ~FILE_STRINGCODE; + } + else { + BLI_makestringcode(G.sce, name); + } + } sfile->returnfunc(name); } @@ -1549,6 +1559,8 @@ static void do_filesel_buttons(short event, SpaceFile *sfile) BLI_cleanup_dir(G.sce, sfile->dir); BLI_make_file_string(G.sce, butname, sfile->dir, ""); + BLI_strncpy(sfile->dir, butname, sizeof(sfile->dir)); + /* strip the trailing slash if its a real dir */ if (strlen(butname)!=1) butname[strlen(butname)-1]=0; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index dd582aa0203..a31f17d1638 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -459,6 +459,8 @@ static void show_splash(void) static void filesel_u_yfexportdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.yfexportdir, dir); @@ -468,6 +470,8 @@ static void filesel_u_yfexportdir(char *name) static void filesel_u_fontdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.fontdir, dir); @@ -477,6 +481,8 @@ static void filesel_u_fontdir(char *name) static void filesel_u_textudir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.textudir, dir); @@ -486,6 +492,8 @@ static void filesel_u_textudir(char *name) static void filesel_u_plugtexdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.plugtexdir, dir); @@ -495,6 +503,8 @@ static void filesel_u_plugtexdir(char *name) static void filesel_u_plugseqdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.plugseqdir, dir); @@ -504,6 +514,8 @@ static void filesel_u_plugseqdir(char *name) static void filesel_u_renderdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.renderdir, dir); @@ -513,6 +525,8 @@ static void filesel_u_renderdir(char *name) static void filesel_u_pythondir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.pythondir, dir); @@ -522,6 +536,8 @@ static void filesel_u_pythondir(char *name) static void filesel_u_sounddir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.sounddir, dir); @@ -531,6 +547,8 @@ static void filesel_u_sounddir(char *name) static void filesel_u_tempdir(char *name) { char dir[FILE_MAXDIR], file[FILE_MAXFILE]; + + BLI_cleanup_dir(G.sce, name); BLI_split_dirfile(name, dir, file); strcpy(U.tempdir, dir); diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c index 381a8482371..27f2248d985 100644 --- a/source/blender/src/usiblender.c +++ b/source/blender/src/usiblender.c @@ -368,6 +368,8 @@ void BIF_read_file(char *name) if(retval==2) init_userdef_file(); // in case a userdef is read from regular .blend + G.relbase_valid = 1; + undo_editmode_clear(); BKE_reset_undo(); BKE_write_undo("original"); /* save current state */ @@ -417,6 +419,7 @@ int BIF_read_homefile(void) } BLI_freelistN(&G.ttfdata); + G.relbase_valid = 0; BLI_make_file_string(G.sce, tstr, home, ".B.blend"); strcpy(scestr, G.sce); /* temporal store */ @@ -558,7 +561,7 @@ static void readBlog(void) fsmenu_append_seperator(); /* add last saved file */ - BLI_split_dirfile(G.sce, name, filename); + BLI_split_dirfile(G.sce, name, filename); /* G.sce shouldn't be relative */ fsmenu_insert_entry(name, 0); @@ -683,6 +686,7 @@ void BIF_write_file(char *target) if (BLO_write_file(di, writeflags, &err)) { strcpy(G.sce, di); + G.relbase_valid = 1; strcpy(G.main->name, di); /* is guaranteed current file */ mainwindow_set_filename_to_title(G.main->name); -- cgit v1.2.3