diff options
author | Julian Eisel <julian@blender.org> | 2020-12-15 18:58:30 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-12-15 19:03:49 +0300 |
commit | 990406e1ff9371a8c896b71171caa876cfdff2f6 (patch) | |
tree | dc726d606be0df6c549bb63a09484e473b3dd2d9 /source/blender/editors/space_file/filesel.c | |
parent | 7dc8db7cd135e7b26fccc1cc6728cac8b510de70 (diff) |
Fix crash when deleting/renaming asset library while it's visible
Storing the asset library reference by name wasn't a good idea, I thought it
would work with a careful fallback, but it's easier to just use the index
instead. So change to using indices, make sure fallback methods work reliable
and make sure the file list is updated when asset libraries are removed.
I added a new notifier type for the latter, I prefer not using file notifiers
in asset-library/preferences code. We have more than enough values for
notifiers left.
Diffstat (limited to 'source/blender/editors/space_file/filesel.c')
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 7 |
1 files changed, 5 insertions, 2 deletions
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; } |