[Bf-blender-cvs] [7b65086fdf9] master: Cleanup: Use new macro for deprecated ID types

Julian Eisel noreply at git.blender.org
Fri May 27 19:17:57 CEST 2022


Commit: 7b65086fdf9cd4e70a6acceff1947e7bd3aa5613
Author: Julian Eisel
Date:   Fri May 27 19:15:58 2022 +0200
Branches: master
https://developer.blender.org/rB7b65086fdf9cd4e70a6acceff1947e7bd3aa5613

Cleanup: Use new macro for deprecated ID types

Uses the macro introduced in b45f410b315 where it makes sense.

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

M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/editors/space_outliner/tree/tree_element_id.cc

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

diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 2f8b3e00df9..528681d196e 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -311,7 +311,7 @@ void id_us_min(ID *id)
     const int limit = ID_FAKE_USERS(id);
 
     if (id->us <= limit) {
-      if (GS(id->name) != ID_IP) {
+      if (!ID_TYPE_IS_DEPRECATED(GS(id->name))) {
         /* Do not assert on deprecated ID types, we cannot really ensure that their ID refcounting
          * is valid... */
         CLOG_ERROR(&LOG,
@@ -590,11 +590,9 @@ static int id_copy_libmanagement_cb(LibraryIDLinkCallbackData *cb_data)
 
 bool BKE_id_copy_is_allowed(const ID *id)
 {
-#define LIB_ID_TYPES_NOCOPY \
-  ID_LI, ID_SCR, ID_WM, ID_WS, /* Not supported */ \
-      ID_IP                    /* Deprecated */
+#define LIB_ID_TYPES_NOCOPY ID_LI, ID_SCR, ID_WM, ID_WS /* Not supported */
 
-  return !ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY);
+  return !ID_TYPE_IS_DEPRECATED(GS(id->name)) && !ELEM(GS(id->name), LIB_ID_TYPES_NOCOPY);
 
 #undef LIB_ID_TYPES_NOCOPY
 }
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc
index ef5e056f229..86f5fd4eff5 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_id.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc
@@ -27,6 +27,11 @@ namespace blender::ed::outliner {
 
 std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_te, ID &id)
 {
+  if (ID_TYPE_IS_DEPRECATED(GS(id.name))) {
+    BLI_assert_msg(0, "Outliner trying to build tree-element for deprecated ID type");
+    return nullptr;
+  }
+
   switch (ID_Type type = GS(id.name); type) {
     case ID_LI:
       return std::make_unique<TreeElementIDLibrary>(legacy_te, (Library &)id);
@@ -70,10 +75,9 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
     case ID_PC:
     case ID_CF:
       return std::make_unique<TreeElementID>(legacy_te, id);
-      /* Deprecated */
     case ID_IP:
-      BLI_assert_msg(0, "Outliner trying to build tree-element for deprecated ID type");
-      return nullptr;
+      BLI_assert_unreachable();
+      break;
   }
 
   return nullptr;



More information about the Bf-blender-cvs mailing list