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:
authorJulian Eisel <julian@blender.org>2021-01-21 23:40:25 +0300
committerJulian Eisel <julian@blender.org>2021-01-22 00:23:43 +0300
commitca475479eb26b4798857b4e67f03eea89324da4b (patch)
tree029cf44f54840f526b5fb85f5f073280d10f24d9 /source/blender/editors/space_file
parent41982af6a0fc8e11cf004a356f97222d7eb72c02 (diff)
Fix Asset Browser showing old name after renaming data-block
The "Current File" asset library didn't get refreshed after the data-block name changed. But rather than entirely refreshing the file list, or doing possibly problematic partial refreshes, reference the data-block name directly, so a simple redraw gets the new name displayed. Addresses T83751
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/filelist.c11
-rw-r--r--source/blender/editors/space_file/space_file.c23
2 files changed, 29 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index d66219c7549..a50751b6b96 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -276,6 +276,7 @@ typedef struct FileListInternEntry {
char *redirection_path;
/** not strictly needed, but used during sorting, avoids to have to recompute it there... */
char *name;
+ bool free_name;
/**
* This is data from the current main, represented by this file. It's crucial that this is
@@ -1366,7 +1367,7 @@ static bool filelist_checkdir_main_assets(struct FileList *UNUSED(filelist),
static void filelist_entry_clear(FileDirEntry *entry)
{
- if (entry->name) {
+ if (entry->name && ((entry->flags & FILE_ENTRY_NAME_FREE) != 0)) {
MEM_freeN(entry->name);
}
if (entry->description) {
@@ -1451,7 +1452,7 @@ static void filelist_intern_entry_free(FileListInternEntry *entry)
if (entry->redirection_path) {
MEM_freeN(entry->redirection_path);
}
- if (entry->name) {
+ if (entry->name && entry->free_name) {
MEM_freeN(entry->name);
}
/* If we own the asset-data (it was generated from external file data), free it. */
@@ -1953,7 +1954,7 @@ static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int in
ret->entry = rev;
ret->relpath = BLI_strdup(entry->relpath);
- ret->name = BLI_strdup(entry->name);
+ ret->name = entry->free_name ? BLI_strdup(entry->name) : entry->name;
ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath);
memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid));
ret->blentype = entry->blentype;
@@ -3175,6 +3176,7 @@ static void filelist_readjob_do(const bool do_lib,
entry->relpath = BLI_strdup(dir + 2); /* + 2 to remove '//'
* added by BLI_path_rel to rel_subdir. */
entry->name = BLI_strdup(fileentry_uiname(root, entry->relpath, entry->typeflag, dir));
+ entry->free_name = true;
/* Here we decide whether current filedirentry is to be listed too, or not. */
if (max_recursion && (is_lib || (recursion_level <= max_recursion))) {
@@ -3288,7 +3290,8 @@ static void filelist_readjob_main_assets(Main *current_main,
entry = MEM_callocN(sizeof(*entry), __func__);
entry->relpath = BLI_strdup(id_code_name);
- entry->name = BLI_strdup(id_iter->name + 2);
+ entry->name = id_iter->name + 2;
+ entry->free_name = false;
entry->typeflag |= FILE_TYPE_BLENDERLIB | FILE_TYPE_ASSET;
entry->blentype = GS(id_iter->name);
*((uint32_t *)entry->uuid) = atomic_add_and_fetch_uint32(
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 193b141d528..9fe380e382f 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -463,6 +463,12 @@ static void file_main_region_listener(const wmRegionListenerParams *params)
break;
}
break;
+ case NC_ID:
+ if (ELEM(wmn->action, NA_RENAME)) {
+ /* In case the filelist shows ID names. */
+ ED_region_tag_redraw(region);
+ }
+ break;
}
}
@@ -650,6 +656,21 @@ static void file_tools_region_listener(const wmRegionListenerParams *UNUSED(para
{
}
+static void file_tool_props_region_listener(const wmRegionListenerParams *params)
+{
+ const wmNotifier *wmn = params->notifier;
+ ARegion *region = params->region;
+
+ switch (wmn->category) {
+ case NC_ID:
+ if (ELEM(wmn->action, NA_RENAME)) {
+ /* In case the filelist shows ID names. */
+ ED_region_tag_redraw(region);
+ }
+ break;
+ }
+}
+
/* add handlers, stuff you only do once or on area/region changes */
static void file_header_region_init(wmWindowManager *wm, ARegion *region)
{
@@ -916,7 +937,7 @@ void ED_spacetype_file(void)
art->prefsizex = 240;
art->prefsizey = 60;
art->keymapflag = ED_KEYMAP_UI;
- art->listener = file_tools_region_listener;
+ art->listener = file_tool_props_region_listener;
art->init = file_tools_region_init;
art->draw = file_tools_region_draw;
BLI_addhead(&st->regiontypes, art);