diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_userpref/userpref_ops.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 9 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 21 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_types.h | 29 |
7 files changed, 49 insertions, 31 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 5dc5f741ac3..afa1fa0edee 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -61,6 +61,7 @@ #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_main_idmap.h" +#include "BKE_preferences.h" #include "BLO_readfile.h" #include "DNA_asset_types.h" @@ -1050,7 +1051,11 @@ static bool filelist_compare_asset_libraries(const FileSelectAssetLibraryUID *li return false; } if (library_a->type == FILE_ASSET_LIBRARY_CUSTOM) { - return STREQ(library_a->custom_library_identifier, library_b->custom_library_identifier); + /* Don't only check the index, also check that it's valid. */ + bUserAssetLibrary *library_ptr_a = BKE_preferences_asset_library_find_from_index( + &U, library_a->custom_library_index); + return (library_ptr_a != NULL) && + (library_a->custom_library_index == library_b->custom_library_index); } return true; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 2c66bd39e0a..cd27b7b5773 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -119,6 +119,7 @@ static void fileselect_ensure_updated_asset_params(SpaceFile *sfile) "FileAssetSelectParams"); asset_params->base_params.details_flags = U_default.file_space_data.details_flags; asset_params->asset_library.type = FILE_ASSET_LIBRARY_LOCAL; + asset_params->asset_library.custom_library_index = -1; } FileSelectParams *base_params = &asset_params->base_params; @@ -419,8 +420,10 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params) /* Ensure valid repo, or fall-back to local one. */ if (library->type == FILE_ASSET_LIBRARY_CUSTOM) { - user_library = BKE_preferences_asset_library_find_from_name( - &U, library->custom_library_identifier); + BLI_assert(library->custom_library_index >= 0); + + user_library = BKE_preferences_asset_library_find_from_index(&U, + library->custom_library_index); if (!user_library) { library->type = FILE_ASSET_LIBRARY_LOCAL; } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 8be02b952a8..09b7e5b348c 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -412,6 +412,11 @@ static void file_listener(wmWindow *UNUSED(win), ED_area_tag_refresh(area); } break; + case ND_SPACE_ASSET_PARAMS: + if (sfile->browse_mode == FILE_BROWSE_MODE_ASSETS) { + ED_area_tag_refresh(area); + } + break; } break; case NC_ASSET: { diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index 9cc8cc6ddaa..ee23cde78c2 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -170,6 +170,8 @@ static int preferences_asset_library_remove_exec(bContext *UNUSED(C), wmOperator if (library) { BKE_preferences_asset_library_remove(&U, library); U.runtime.is_dirty = true; + /* Trigger refresh for the Asset Browser. */ + WM_main_add_notifier(NC_SPACE | ND_SPACE_ASSET_PARAMS, NULL); } return OPERATOR_FINISHED; } diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index e07f085d356..4161faca386 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -673,12 +673,13 @@ typedef enum eSpaceSeq_OverlayType { */ typedef struct FileSelectAssetLibraryUID { short type; - char _pad[6]; + char _pad[2]; /** - * If showing a custom asset library (#FILE_ASSET_LIBRARY_CUSTOM), this name has to be set to - * define which. Can be empty otherwise. + * If showing a custom asset library (#FILE_ASSET_LIBRARY_CUSTOM), this is the index of the + * #bUserAssetLibrary within #UserDef.asset_libraries. + * Should be ignored otherwise (but better set to -1 then, for sanity and debugging). */ - char custom_library_identifier[64]; /* MAX_NAME */ + int custom_library_index; } FileSelectAssetLibraryUID; /* Config and Input for File Selector */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 59012ce4528..0e779c8cc97 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2482,11 +2482,10 @@ static int rna_FileAssetSelectParams_asset_library_get(PointerRNA *ptr) /* Note that the path isn't checked for validity here. If an invalid library path is used, the * Asset Browser can give a nice hint on what's wrong. */ - const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_name( - &U, params->asset_library.custom_library_identifier); - const int index = BKE_preferences_asset_library_get_index(&U, user_library); - if (index > -1) { - return FILE_ASSET_LIBRARY_CUSTOM + index; + const bUserAssetLibrary *user_library = BKE_preferences_asset_library_find_from_index( + &U, params->asset_library.custom_library_index); + if (user_library) { + return FILE_ASSET_LIBRARY_CUSTOM + params->asset_library.custom_library_index; } BLI_assert(0); @@ -2500,7 +2499,7 @@ static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int val /* Simple case: Predefined repo, just set the value. */ if (value < FILE_ASSET_LIBRARY_CUSTOM) { params->asset_library.type = value; - params->asset_library.custom_library_identifier[0] = '\0'; + params->asset_library.custom_library_index = -1; BLI_assert(ELEM(value, FILE_ASSET_LIBRARY_LOCAL)); return; } @@ -2511,10 +2510,12 @@ static void rna_FileAssetSelectParams_asset_library_set(PointerRNA *ptr, int val /* Note that the path isn't checked for validity here. If an invalid library path is used, the * Asset Browser can give a nice hint on what's wrong. */ const bool is_valid = (user_library->name[0] && user_library->path[0]); - if (user_library && is_valid) { - BLI_strncpy(params->asset_library.custom_library_identifier, - user_library->name, - sizeof(params->asset_library.custom_library_identifier)); + if (!user_library) { + params->asset_library.type = FILE_ASSET_LIBRARY_LOCAL; + params->asset_library.custom_library_index = -1; + } + else if (user_library && is_valid) { + params->asset_library.custom_library_index = value - FILE_ASSET_LIBRARY_CUSTOM; params->asset_library.type = FILE_ASSET_LIBRARY_CUSTOM; } } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 0ddd0f20c7a..a2cc246e21e 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -410,20 +410,21 @@ typedef struct wmNotifier { #define ND_SPACE_IMAGE (4 << 16) #define ND_SPACE_FILE_PARAMS (5 << 16) #define ND_SPACE_FILE_LIST (6 << 16) -#define ND_SPACE_NODE (7 << 16) -#define ND_SPACE_OUTLINER (8 << 16) -#define ND_SPACE_VIEW3D (9 << 16) -#define ND_SPACE_PROPERTIES (10 << 16) -#define ND_SPACE_TEXT (11 << 16) -#define ND_SPACE_TIME (12 << 16) -#define ND_SPACE_GRAPH (13 << 16) -#define ND_SPACE_DOPESHEET (14 << 16) -#define ND_SPACE_NLA (15 << 16) -#define ND_SPACE_SEQUENCER (16 << 16) -#define ND_SPACE_NODE_VIEW (17 << 16) -#define ND_SPACE_CHANGED (18 << 16) /*sent to a new editor type after it's replaced an old one*/ -#define ND_SPACE_CLIP (19 << 16) -#define ND_SPACE_FILE_PREVIEW (20 << 16) +#define ND_SPACE_ASSET_PARAMS (7 << 16) +#define ND_SPACE_NODE (8 << 16) +#define ND_SPACE_OUTLINER (9 << 16) +#define ND_SPACE_VIEW3D (10 << 16) +#define ND_SPACE_PROPERTIES (11 << 16) +#define ND_SPACE_TEXT (12 << 16) +#define ND_SPACE_TIME (13 << 16) +#define ND_SPACE_GRAPH (14 << 16) +#define ND_SPACE_DOPESHEET (15 << 16) +#define ND_SPACE_NLA (16 << 16) +#define ND_SPACE_SEQUENCER (17 << 16) +#define ND_SPACE_NODE_VIEW (18 << 16) +#define ND_SPACE_CHANGED (19 << 16) /*sent to a new editor type after it's replaced an old one*/ +#define ND_SPACE_CLIP (20 << 16) +#define ND_SPACE_FILE_PREVIEW (21 << 16) /* subtype, 256 entries too */ #define NOTE_SUBTYPE 0x0000FF00 |