2.5 filebrowser
authorAndrea Weikert <elubie@gmx.net>
Tue, 15 Sep 2009 20:47:34 +0000 (20:47 +0000)
committerAndrea Weikert <elubie@gmx.net>
Tue, 15 Sep 2009 20:47:34 +0000 (20:47 +0000)
bugfix #1: SpaceFile->files needs to be deleted on exec and cancel of the filebrowser and in init to ensure correct setting of the read function.
bugfix #2: SpaceFile->params needs to be set in file_init otherwise Python can't access params in header ui.

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

index d2d1d11ec5cbe7137bbeb90b2319aa6145b01990..0e0ad88906eaaaccf9eace11d461e3e1ba168136 100644 (file)
@@ -496,6 +496,12 @@ int file_cancel_exec(bContext *C, wmOperator *unused)
        WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_CANCEL);
        sfile->op = NULL;
        
+       if (sfile->files) {
+               filelist_free(sfile->files);
+               MEM_freeN(sfile->files);
+               sfile->files= NULL;
+       }
+       
        return OPERATOR_FINISHED;
 }
 
@@ -567,6 +573,10 @@ int file_exec(bContext *C, wmOperator *unused)
                BLI_make_file_string(G.sce, name, BLI_gethome(), ".Bfs");
                fsmenu_write_file(fsmenu_get(), name);
                WM_event_fileselect_event(C, op, EVT_FILESELECT_EXEC);
+
+               filelist_free(sfile->files);
+               MEM_freeN(sfile->files);
+               sfile->files= NULL;
        }
                                
        return OPERATOR_FINISHED;
index 085eecd2a7ddbf604b70f8dce669fd9bd5346722..a0787ef989d8c47a613e4d4133ece27ac8745e2c 100644 (file)
@@ -169,18 +169,13 @@ short ED_fileselect_set_params(SpaceFile *sfile)
                
        } else {
                /* default values, if no operator */
+               params->type = FILE_UNIX;
                params->flag |= FILE_HIDE_DOT;
                params->display = FILE_SHORTDISPLAY;
                params->filter = 0;
                params->sort = FILE_SORT_ALPHA;
        }
 
-       /* new params, refresh file list */
-       if(sfile->files) { 
-               filelist_free(sfile->files);
-               filelist_setdir(sfile->files, params->dir);
-       }
-
        return 1;
 }
 
index 68eeb8718a2424ee19feda5eb42fa25ba31d5bb2..27948618d034ef481c046e282596b3791da9af08 100644 (file)
@@ -159,6 +159,12 @@ static void file_init(struct wmWindowManager *wm, ScrArea *sa)
        if(sfile->params) {
                MEM_freeN(sfile->params);
                sfile->params = 0;
+               ED_fileselect_set_params(sfile);
+               if (sfile->files) {
+                       filelist_free(sfile->files);
+                       MEM_freeN(sfile->files);
+                       sfile->files= NULL;
+               }
        }
        printf("file_init\n");
 }