Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2018-06-18 13:26:47 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-06-18 13:26:47 +0300
commit579631819f0136ab0fbb0f6c7c21265b468940dc (patch)
tree4c5ee6372525cb87827e0c09c7ffb03cc35b888a /source/blender/makesrna
parentb66ae8259e01526bb682c5081c4c0146416f8908 (diff)
Fix T55503: File browser filter not working correctly.
There were two issues here, introduced by rB66aa4af836: * Forgot to change length of some filter_glob var deep in filebrowser code. * Truncating filter_glob in general can be dangerous, generating unexpected patterns. Last point was the root of the issue here, truncating to 63 chars string left last group as 'match everything' `*` pattern. To fix that to some extent, added a new BLI_path_extension_glob_validate helper to BLI_path_util, which ensures we do not have last wildcards-only group in our pattern, when there are more than one group.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_space.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index a3ba43db2d4..c69679185aa 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -258,6 +258,8 @@ const EnumPropertyItem rna_enum_file_sort_items[] = {
#include "DNA_userdef_types.h"
#include "BLI_math.h"
+#include "BLI_path_util.h"
+#include "BLI_string.h"
#include "BKE_animsys.h"
#include "BKE_brush.h"
@@ -1634,6 +1636,16 @@ static const EnumPropertyItem *rna_FileSelectParams_recursion_level_itemf(
return fileselectparams_recursion_level_items;
}
+static void rna_FileSelectPrams_filter_glob_set(PointerRNA *ptr, const char *value)
+{
+ FileSelectParams *params = ptr->data;
+
+ BLI_strncpy(params->filter_glob, value, sizeof(params->filter_glob));
+
+ /* Remove stupi things like last group being a wildcard-only one... */
+ BLI_path_extension_glob_validate(params->filter_glob);
+}
+
static void rna_FileBrowser_FSMenuEntry_path_get(PointerRNA *ptr, char *value)
{
char *path = ED_fsmenu_entry_get_path(ptr->data);
@@ -4038,7 +4050,10 @@ static void rna_def_fileselect_params(BlenderRNA *brna)
prop = RNA_def_property(srna, "filter_glob", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "filter_glob");
- RNA_def_property_ui_text(prop, "Extension Filter", "");
+ RNA_def_property_ui_text(prop, "Extension Filter",
+ "UNIX shell-like filename patterns matching, supports wildcards ('*') "
+ "and list of patterns separated by ';'");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FileSelectPrams_filter_glob_set");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
prop = RNA_def_property(srna, "filter_search", PROP_STRING, PROP_NONE);