Fix T52109: Folder search won't work when selecting animation output folder.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 18 Jul 2017 14:01:28 +0000 (16:01 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 18 Jul 2017 14:01:28 +0000 (16:01 +0200)
Text search would not run in case there was no 'type' enabled in filter
buttons. Now instead consider that no types enabled == all types
enabled.

source/blender/editors/space_file/filelist.c
source/blender/editors/space_file/filelist.h
source/blender/editors/space_file/space_file.c

index 6c33091ff011df10a76eed3c3d44f524e829dc89..8e548d7a9bd43894903a8813ff47669cb77669a9 100644 (file)
@@ -277,9 +277,10 @@ typedef struct FileListFilter {
 
 /* FileListFilter.flags */
 enum {
-       FLF_HIDE_DOT     = 1 << 0,
-       FLF_HIDE_PARENT  = 1 << 1,
-       FLF_HIDE_LIB_DIR = 1 << 2,
+       FLF_DO_FILTER    = 1 << 0,
+       FLF_HIDE_DOT     = 1 << 1,
+       FLF_HIDE_PARENT  = 1 << 2,
+       FLF_HIDE_LIB_DIR = 1 << 3,
 };
 
 typedef struct FileList {
@@ -594,24 +595,27 @@ static bool is_filtered_file(FileListInternEntry *file, const char *UNUSED(root)
 {
        bool is_filtered = !is_hidden_file(file->relpath, filter);
 
-       if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
-               if (file->typeflag & FILE_TYPE_DIR) {
-                       if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
-                               if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
-                                       is_filtered = false;
+       if (is_filtered && (filter->flags & FLF_DO_FILTER) && !FILENAME_IS_CURRPAR(file->relpath)) {
+               /* We only check for types if some type are enabled in filtering. */
+               if (filter->filter) {
+                       if (file->typeflag & FILE_TYPE_DIR) {
+                               if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
+                                       if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
+                                               is_filtered = false;
+                                       }
+                               }
+                               else {
+                                       if (!(filter->filter & FILE_TYPE_FOLDER)) {
+                                               is_filtered = false;
+                                       }
                                }
                        }
                        else {
-                               if (!(filter->filter & FILE_TYPE_FOLDER)) {
+                               if (!(file->typeflag & filter->filter)) {
                                        is_filtered = false;
                                }
                        }
                }
-               else {
-                       if (!(file->typeflag & filter->filter)) {
-                               is_filtered = false;
-                       }
-               }
                if (is_filtered && (filter->filter_search[0] != '\0')) {
                        if (fnmatch(filter->filter_search, file->relpath, FNM_CASEFOLD) != 0) {
                                is_filtered = false;
@@ -631,28 +635,31 @@ static bool is_filtered_lib(FileListInternEntry *file, const char *root, FileLis
 
        if (BLO_library_path_explode(path, dir, &group, &name)) {
                is_filtered = !is_hidden_file(file->relpath, filter);
-               if (is_filtered && filter->filter && !FILENAME_IS_CURRPAR(file->relpath)) {
-                       if (file->typeflag & FILE_TYPE_DIR) {
-                               if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
-                                       if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
-                                               is_filtered = false;
+               if (is_filtered && (filter->flags & FLF_DO_FILTER) && !FILENAME_IS_CURRPAR(file->relpath)) {
+                       /* We only check for types if some type are enabled in filtering. */
+                       if (filter->filter || filter->filter_id) {
+                               if (file->typeflag & FILE_TYPE_DIR) {
+                                       if (file->typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP)) {
+                                               if (!(filter->filter & (FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP))) {
+                                                       is_filtered = false;
+                                               }
                                        }
-                               }
-                               else {
-                                       if (!(filter->filter & FILE_TYPE_FOLDER)) {
-                                               is_filtered = false;
+                                       else {
+                                               if (!(filter->filter & FILE_TYPE_FOLDER)) {
+                                                       is_filtered = false;
+                                               }
                                        }
                                }
-                       }
-                       if (is_filtered && group) {
-                               if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) {
-                                       is_filtered = false;
-                               }
-                               else {
-                                       unsigned int filter_id = groupname_to_filter_id(group);
-                                       if (!(filter_id & filter->filter_id)) {
+                               if (is_filtered && group) {
+                                       if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) {
                                                is_filtered = false;
                                        }
+                                       else {
+                                               unsigned int filter_id = groupname_to_filter_id(group);
+                                               if (!(filter_id & filter->filter_id)) {
+                                                       is_filtered = false;
+                                               }
+                                       }
                                }
                        }
                        if (is_filtered && (filter->filter_search[0] != '\0')) {
@@ -729,12 +736,17 @@ void filelist_filter(FileList *filelist)
        MEM_freeN(filtered_tmp);
 }
 
-void filelist_setfilter_options(FileList *filelist, const bool hide_dot, const bool hide_parent,
+void filelist_setfilter_options(FileList *filelist, const bool do_filter,
+                                const bool hide_dot, const bool hide_parent,
                                 const unsigned int filter, const unsigned int filter_id,
                                 const char *filter_glob, const char *filter_search)
 {
        bool update = false;
 
+       if (((filelist->filter_data.flags & FLF_DO_FILTER) != 0) != (do_filter != 0)) {
+               filelist->filter_data.flags ^= FLF_DO_FILTER;
+               update = true;
+       }
        if (((filelist->filter_data.flags & FLF_HIDE_DOT) != 0) != (hide_dot != 0)) {
                filelist->filter_data.flags ^= FLF_HIDE_DOT;
                update = true;
index f4304681780a5e8569829205f89f3ae1308b71de..4e9c1e0dd1dd0fb1f5e293b76f83fa1495fbc336 100644 (file)
@@ -68,7 +68,8 @@ int                 folderlist_clear_next(struct SpaceFile *sfile);
 void                filelist_setsorting(struct FileList *filelist, const short sort);
 void                filelist_sort(struct FileList *filelist);
 
-void                filelist_setfilter_options(struct FileList *filelist, const bool hide_dot, const bool hide_parent,
+void                filelist_setfilter_options(struct FileList *filelist, const bool do_filter,
+                                               const bool hide_dot, const bool hide_parent,
                                                const unsigned int filter, const unsigned int filter_id,
                                                const char *filter_glob, const char *filter_search);
 void                filelist_filter(struct FileList *filelist);
index 374db92297d5d3cc355ac3662c2d64f75811bd9b..287b98fa58974c0c4a256b310ef98a4acc1cf37b 100644 (file)
@@ -223,9 +223,10 @@ static void file_refresh(const bContext *C, ScrArea *sa)
        filelist_setdir(sfile->files, params->dir);
        filelist_setrecursion(sfile->files, params->recursion_level);
        filelist_setsorting(sfile->files, params->sort);
-       filelist_setfilter_options(sfile->files, (params->flag & FILE_HIDE_DOT) != 0,
+       filelist_setfilter_options(sfile->files, (params->flag & FILE_FILTER) != 0,
+                                                (params->flag & FILE_HIDE_DOT) != 0,
                                                 false, /* TODO hide_parent, should be controllable? */
-                                                (params->flag & FILE_FILTER) ? params->filter : 0,
+                                                params->filter,
                                                 params->filter_id,
                                                 params->filter_glob,
                                                 params->filter_search);