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:
authorSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-11-19 21:34:44 +0300
committerSiddhartha Jejurkar <f20180617@goa.bits-pilani.ac.in>2021-11-19 21:34:44 +0300
commit99a2af76d10e05a18987be5d554ada197b1ca086 (patch)
tree9f9ceccccbd117c05a701b6769eb69055be6a28e /source/blender/editors/space_file/filelist.c
parent139606bd370f96e0a8685547d515a2335591d5de (diff)
parent50ad0e15fe0adde7335c89c6fcfa0948c341a08a (diff)
Merge branch 'master' into soc-2021-uv-edge-select-support
Diffstat (limited to 'source/blender/editors/space_file/filelist.c')
-rw-r--r--source/blender/editors/space_file/filelist.c59
1 files changed, 24 insertions, 35 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a73fa2b9740..b85dadf1f8e 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -914,24 +914,14 @@ static void prepare_filter_asset_library(const FileList *filelist, FileListFilte
if (!filter->asset_catalog_filter) {
return;
}
+ BLI_assert_msg(filelist->asset_library,
+ "prepare_filter_asset_library() should only be called when the file browser is "
+ "in asset browser mode");
file_ensure_updated_catalog_filter_data(filter->asset_catalog_filter, filelist->asset_library);
}
/**
- * Copy a string from source to `dest`, but prefix and suffix it with a single space.
- * Assumes `dest` has at least space enough for the two spaces.
- */
-static void tag_copy_with_spaces(char *dest, const char *source, const size_t dest_size)
-{
- BLI_assert(dest_size > 2);
- const size_t source_length = BLI_strncpy_rlen(dest + 1, source, dest_size - 2);
- dest[0] = ' ';
- dest[source_length + 1] = ' ';
- dest[source_length + 2] = '\0';
-}
-
-/**
* Return whether at least one tag matches the search filter.
* Tags are searched as "entire words", so instead of searching for "tag" in the
* filter string, this function searches for " tag ". Assumes the search filter
@@ -946,9 +936,7 @@ static void tag_copy_with_spaces(char *dest, const char *source, const size_t de
static bool asset_tag_matches_filter(const char *filter_search, const AssetMetaData *asset_data)
{
LISTBASE_FOREACH (const AssetTag *, asset_tag, &asset_data->tags) {
- char tag_name[MAX_NAME + 2]; /* sizeof(AssetTag::name) + 2 */
- tag_copy_with_spaces(tag_name, asset_tag->name, sizeof(tag_name));
- if (BLI_strcasestr(filter_search, tag_name) != NULL) {
+ if (BLI_strcasestr(asset_tag->name, filter_search) != NULL) {
return true;
}
}
@@ -979,13 +967,7 @@ static bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter)
if (BLI_strcasestr(file->name, filter_search + 1) != NULL) {
return true;
}
-
- /* Replace the asterisks with spaces, so that we can do matching on " sometag "; that way
- * an artist searching for "redder" doesn't result in a match for the tag "red". */
- filter_search[string_length - 1] = ' ';
- filter_search[0] = ' ';
-
- return asset_tag_matches_filter(filter_search, asset_data);
+ return asset_tag_matches_filter(filter_search + 1, asset_data);
}
static bool is_filtered_lib_type(FileListInternEntry *file,
@@ -1728,7 +1710,7 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
return;
}
- if (entry->flags & FILE_ENTRY_INVALID_PREVIEW) {
+ if (entry->flags & (FILE_ENTRY_INVALID_PREVIEW | FILE_ENTRY_PREVIEW_LOADING)) {
return;
}
@@ -1759,6 +1741,7 @@ static void filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry
FileListEntryPreviewTaskData *preview_taskdata = MEM_mallocN(sizeof(*preview_taskdata),
__func__);
preview_taskdata->preview = preview;
+ entry->flags |= FILE_ENTRY_PREVIEW_LOADING;
BLI_task_pool_push(cache->previews_pool,
filelist_cache_preview_runf,
preview_taskdata,
@@ -1876,11 +1859,13 @@ void filelist_settype(FileList *filelist, short type)
case FILE_MAIN:
filelist->check_dir_fn = filelist_checkdir_main;
filelist->read_job_fn = filelist_readjob_main;
+ filelist->prepare_filter_fn = NULL;
filelist->filter_fn = is_filtered_main;
break;
case FILE_LOADLIB:
filelist->check_dir_fn = filelist_checkdir_lib;
filelist->read_job_fn = filelist_readjob_lib;
+ filelist->prepare_filter_fn = NULL;
filelist->filter_fn = is_filtered_lib;
break;
case FILE_ASSET_LIBRARY:
@@ -1900,6 +1885,7 @@ void filelist_settype(FileList *filelist, short type)
default:
filelist->check_dir_fn = filelist_checkdir_dir;
filelist->read_job_fn = filelist_readjob_dir;
+ filelist->prepare_filter_fn = NULL;
filelist->filter_fn = is_filtered_file;
break;
}
@@ -2674,24 +2660,27 @@ bool filelist_cache_previews_update(FileList *filelist)
// printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img);
- if (preview->icon_id) {
- /* Due to asynchronous process, a preview for a given image may be generated several times,
- * i.e. entry->image may already be set at this point. */
- if (entry && !entry->preview_icon_id) {
+ if (entry) {
+ entry->flags &= ~FILE_ENTRY_PREVIEW_LOADING;
+ if (preview->icon_id) {
+ /* The FILE_ENTRY_PREVIEW_LOADING flag should have prevented any other asynchronous
+ * process from trying to generate the same preview icon. */
+ BLI_assert_msg(!entry->preview_icon_id, "Preview icon should not have been generated yet");
+
/* Move ownership over icon. */
entry->preview_icon_id = preview->icon_id;
preview->icon_id = 0;
changed = true;
}
else {
- BKE_icon_delete(preview->icon_id);
+ /* We want to avoid re-processing this entry continuously!
+ * Note that, since entries only live in cache,
+ * preview will be retried quite often anyway. */
+ entry->flags |= FILE_ENTRY_INVALID_PREVIEW;
}
}
- else if (entry) {
- /* We want to avoid re-processing this entry continuously!
- * Note that, since entries only live in cache,
- * preview will be retried quite often anyway. */
- entry->flags |= FILE_ENTRY_INVALID_PREVIEW;
+ else {
+ BKE_icon_delete(preview->icon_id);
}
MEM_freeN(preview);
@@ -3711,7 +3700,7 @@ static void filelist_readjob_main_assets_add_items(FileListReadJob *job_params,
BKE_main_lock(job_params->current_main);
FOREACH_MAIN_ID_BEGIN (job_params->current_main, id_iter) {
- if (!id_iter->asset_data) {
+ if (!id_iter->asset_data || ID_IS_LINKED(id_iter)) {
continue;
}