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>2020-12-15 18:58:30 +0300
committerJulian Eisel <julian@blender.org>2020-12-15 19:03:49 +0300
commit990406e1ff9371a8c896b71171caa876cfdff2f6 (patch)
treedc726d606be0df6c549bb63a09484e473b3dd2d9 /source/blender/editors
parent7dc8db7cd135e7b26fccc1cc6728cac8b510de70 (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')
-rw-r--r--source/blender/editors/space_file/filelist.c7
-rw-r--r--source/blender/editors/space_file/filesel.c7
-rw-r--r--source/blender/editors/space_file/space_file.c5
-rw-r--r--source/blender/editors/space_userpref/userpref_ops.c2
4 files changed, 18 insertions, 3 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;
}