2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Sun, 13 Sep 2009 08:08:50 +0000 (08:08 +0000)
committerAndrea Weikert <elubie@gmx.net>
Sun, 13 Sep 2009 08:08:50 +0000 (08:08 +0000)
Fix crash when loading old files with filebrowser UI
Partial Fix for invoking filebrowser via spacetype pupmenu: reset directory in filelist
Make paths relative in 'path' return when requested by 'relative_paths' property in operator

source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/space_file.c

index 5d3c2c766a3815e7b2e46c1b10e79a902a7c1140..e51fd421c8cd5668705a9a59997fa884f378fa9a 100644 (file)
@@ -524,6 +524,10 @@ int file_exec(bContext *C, wmOperator *unused)
                BLI_strncpy(name, sfile->params->dir, sizeof(name));
                RNA_string_set(op->ptr, "directory", name);
                strcat(name, sfile->params->file);
+
+               if ( RNA_boolean_get(op->ptr, "relative_paths") ) {
+                       BLI_makestringcode(G.sce, name);
+               }
                RNA_string_set(op->ptr, "path", name);
                
                /* some ops have multiple files to select */
index e22e9f8e02339f84b468ee207475fa29f8cdb5ab..f226b3de2602bcbfdc6ac5556b858fee65003caa 100644 (file)
@@ -117,6 +117,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                BLI_strncpy(sfile->params->file, file, sizeof(sfile->params->file));
                BLI_make_file_string(G.sce, sfile->params->dir, dir, ""); /* XXX needed ? - also solve G.sce */
        }
+       
+       ED_fileselect_reset_params(sfile);
 
        params = sfile->params;
 
@@ -173,13 +175,17 @@ short ED_fileselect_set_params(SpaceFile *sfile)
        }
 
        /* new params, refresh file list */
-       if(sfile->files) filelist_free(sfile->files);
+       if(sfile->files) { 
+               filelist_free(sfile->files);
+               filelist_setdir(sfile->files, params->dir);
+       }
 
        return 1;
 }
 
 void ED_fileselect_reset_params(SpaceFile *sfile)
 {
+       sfile->params->type = FILE_UNIX;
        sfile->params->flag = 0;
        sfile->params->title[0] = '\0';
 }
index f71defe3949e4845b98d25058b8adfd64426cc0f..bceeec1cb5517e035e13f4e22791c096d8b6a5b7 100644 (file)
@@ -166,7 +166,8 @@ static SpaceLink *file_duplicate(SpaceLink *sl)
        /* clear or remove stuff from old */
        sfilen->op = NULL; /* file window doesn't own operators */
 
-       sfilen->files = filelist_new(sfileo->params->type);
+       if (sfileo->params)
+               sfilen->files = filelist_new(sfileo->params->type);
        if(sfileo->folders_prev)
                sfilen->folders_prev = MEM_dupallocN(sfileo->folders_prev);