[Bf-blender-cvs] [e1d90eccc54] blender-projects-basics: Fix error when changing asset library name or path

Julian Eisel noreply at git.blender.org
Tue Oct 18 16:24:51 CEST 2022


Commit: e1d90eccc5474ac7f689be57be78a265a2aa96b7
Author: Julian Eisel
Date:   Tue Oct 18 16:23:53 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rBe1d90eccc5474ac7f689be57be78a265a2aa96b7

Fix error when changing asset library name or path

Coded the RNA functions to only work with the preferences for the
start. But we actually don't have to care here if the libraries are
defined in the preferences or project.

===================================================================

M	source/blender/makesrna/intern/rna_asset.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c
index fc5bfeea5d2..a04fdbae465 100644
--- a/source/blender/makesrna/intern/rna_asset.c
+++ b/source/blender/makesrna/intern/rna_asset.c
@@ -258,30 +258,19 @@ void rna_AssetMetaData_catalog_id_update(struct bContext *C, struct PointerRNA *
   BKE_asset_library_refresh_catalog_simplename(asset_library, asset_data);
 }
 
-static bool rna_CustomAssetLibraryDefinition_is_from_prefs(
-    const CustomAssetLibraryDefinition *library)
-{
-  return BLI_findindex(&U.asset_libraries, library) > -1;
-}
-
 static void rna_CustomAssetLibraryDefinition_name_set(PointerRNA *ptr, const char *value)
 {
   CustomAssetLibraryDefinition *library = (CustomAssetLibraryDefinition *)ptr->data;
-  if (!rna_CustomAssetLibraryDefinition_is_from_prefs(library)) {
-    BLI_assert_unreachable();
-    return;
-  }
 
-  BKE_asset_library_custom_name_set(&U.asset_libraries, library, value);
+  /* We can't cleanly access the owning listbase here, but reconstructing the list from the link is
+   * fine. */
+  ListBase asset_libraries = BLI_listbase_from_link((Link *)library);
+  BKE_asset_library_custom_name_set(&asset_libraries, library, value);
 }
 
 static void rna_CustomAssetLibraryDefinition_path_set(PointerRNA *ptr, const char *value)
 {
   CustomAssetLibraryDefinition *library = (CustomAssetLibraryDefinition *)ptr->data;
-  if (!rna_CustomAssetLibraryDefinition_is_from_prefs(library)) {
-    BLI_assert_unreachable();
-    return;
-  }
 
   char dirpath[FILE_MAX];
   BLI_strncpy(dirpath, value, sizeof(dirpath));



More information about the Bf-blender-cvs mailing list