diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_space.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 21 |
1 files changed, 11 insertions, 10 deletions
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; } } |