[Bf-blender-cvs] [17e1fef85aa] master: Cleanup: Library: Move to IDTypeInfo, and remove unused BKE API.

Bastien Montagne noreply at git.blender.org
Fri Mar 6 11:28:09 CET 2020


Commit: 17e1fef85aa45f95d2e7c872901ca1c6140fad73
Author: Bastien Montagne
Date:   Fri Mar 6 11:27:29 2020 +0100
Branches: master
https://developer.blender.org/rB17e1fef85aa45f95d2e7c872901ca1c6140fad73

Cleanup: Library: Move to IDTypeInfo, and remove unused BKE API.

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

M	source/blender/blenkernel/BKE_idtype.h
M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/idtype.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/library.c

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

diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 84412942e9a..2e8b39c938c 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -125,6 +125,7 @@ typedef struct IDTypeInfo {
 
 /* Those are defined in the respective BKE files. */
 extern IDTypeInfo IDType_ID_SCE;
+extern IDTypeInfo IDType_ID_LI;
 extern IDTypeInfo IDType_ID_OB;
 
 /* ********** Helpers/Utils API. ********** */
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 1324e4ebf90..5bc3d50bf8d 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -34,8 +34,6 @@ extern "C" {
 struct Library;
 struct Main;
 
-void BKE_library_free(struct Library *lib);
-
 void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const char *filepath);
 
 #ifdef __cplusplus
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 6161e41db4e..1453234d577 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -52,6 +52,7 @@ static void id_type_init(void)
   (void)0
 
   INIT_TYPE(ID_SCE);
+  INIT_TYPE(ID_LI);
   INIT_TYPE(ID_OB);
 
 #undef INIT_TYPE
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 77ab4d1eb2a..e311dd2ef03 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -140,7 +140,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
       BLI_assert(0);
       break;
     case ID_LI:
-      BKE_library_free((Library *)id);
+      BLI_assert(0);
       break;
     case ID_OB:
       BLI_assert(0);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 376d5aacbf5..e3ed21aa536 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -34,6 +34,9 @@
 
 #include "BLI_blenlib.h"
 
+#include "BLT_translation.h"
+
+#include "BKE_idtype.h"
 #include "BKE_lib_id.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
@@ -42,13 +45,30 @@
 /* Unused currently. */
 // static CLG_LogRef LOG = {.identifier = "bke.library"};
 
-void BKE_library_free(Library *lib)
+static void library_free_data(ID *id)
 {
-  if (lib->packedfile) {
-    BKE_packedfile_free(lib->packedfile);
+  Library *library = (Library *)id;
+  if (library->packedfile) {
+    BKE_packedfile_free(library->packedfile);
   }
 }
 
+IDTypeInfo IDType_ID_LI = {
+    .id_code = ID_LI,
+    .id_filter = 0,
+    .main_listbase_index = INDEX_ID_LI,
+    .struct_size = sizeof(Library),
+    .name = "Library",
+    .name_plural = "libraries",
+    .translation_context = BLT_I18NCONTEXT_ID_LIBRARY,
+    .flags = IDTYPE_FLAGS_NO_COPY | IDTYPE_FLAGS_NO_LIBLINKING | IDTYPE_FLAGS_NO_MAKELOCAL,
+
+    .init_data = NULL,
+    .copy_data = NULL,
+    .free_data = library_free_data,
+    .make_local = NULL,
+};
+
 void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
 {
   /* in some cases this is used to update the absolute path from the



More information about the Bf-blender-cvs mailing list