[Bf-blender-cvs] [b5e3700b793] master: Cleanup: Replace direct `id.lib` pointer checks with `ID_IS_LINKED` macro usages.

Bastien Montagne noreply at git.blender.org
Thu Feb 17 17:08:06 CET 2022


Commit: b5e3700b793f730b404315493ceadb60e4af708d
Author: Bastien Montagne
Date:   Thu Feb 17 17:07:25 2022 +0100
Branches: master
https://developer.blender.org/rBb5e3700b793f730b404315493ceadb60e4af708d

Cleanup: Replace direct `id.lib` pointer checks with `ID_IS_LINKED` macro usages.

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

M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/blenloader/intern/versioning_common.cc
M	source/blender/editors/util/ed_util_ops.cc
M	source/blender/makesdna/DNA_scene_types.h

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

diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index f091ebe1e32..4531783c72a 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -147,7 +147,7 @@ static void brush_make_local(Main *bmain, ID *id, const int flags)
     /* NOTE: assert below ensures that the comment above is valid, and that that exception is
      * acceptable for the time being. */
     BKE_lib_id_make_local(bmain, &brush->clone.image->id, 0);
-    BLI_assert(brush->clone.image->id.lib == NULL && brush->clone.image->id.newid == NULL);
+    BLI_assert(!ID_IS_LINKED(brush->clone.image) && brush->clone.image->id.newid == NULL);
   }
 
   if (force_local) {
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index cf25af1c637..ba5556c8b2d 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -234,7 +234,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
         for (id = lb->first; id; id = id_next) {
           id_next = id->next;
           /* NOTE: in case we delete a library, we also delete all its datablocks! */
-          if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) {
+          if ((id->tag & tag) || (ID_IS_LINKED(id) && (id->lib->id.tag & tag))) {
             BLI_remlink(lb, id);
             BLI_addtail(&tagged_deleted_ids, id);
             /* Do not tag as no_main now, we want to unlink it first (lower-level ID management
@@ -290,7 +290,7 @@ static size_t id_delete(Main *bmain, const bool do_tagged_deletion)
       for (id = lb->first; id; id = id_next) {
         id_next = id->next;
         /* NOTE: in case we delete a library, we also delete all its datablocks! */
-        if ((id->tag & tag) || (id->lib != NULL && (id->lib->id.tag & tag))) {
+        if ((id->tag & tag) || (ID_IS_LINKED(id) && (id->lib->id.tag & tag))) {
           id->tag |= tag;
           BKE_id_remapper_add(remapper, id, NULL);
         }
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 02cdd6fcd20..8a988bd30b5 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -2127,7 +2127,7 @@ static void lib_override_library_main_resync_on_library_indirect_level(
                  "ID override %s from library level %d still found as needing resync, when all "
                  "IDs from that level should have been processed after tackling library level %d",
                  id->name,
-                 id->lib != NULL ? id->lib->temp_index : 0,
+                 ID_IS_LINKED(id) ? id->lib->temp_index : 0,
                  library_indirect_level);
       id->tag &= ~LIB_TAG_LIB_OVERRIDE_NEED_RESYNC;
     }
diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc
index 6aac76642d5..281769410bd 100644
--- a/source/blender/blenloader/intern/versioning_common.cc
+++ b/source/blender/blenloader/intern/versioning_common.cc
@@ -56,7 +56,7 @@ ID *do_versions_rename_id(Main *bmain,
   ListBase *lb = which_libbase(bmain, id_type);
   ID *id = nullptr;
   LISTBASE_FOREACH (ID *, idtest, lb) {
-    if (idtest->lib == nullptr) {
+    if (!ID_IS_LINKED(idtest)) {
       if (STREQ(idtest->name + 2, name_src)) {
         id = idtest;
       }
diff --git a/source/blender/editors/util/ed_util_ops.cc b/source/blender/editors/util/ed_util_ops.cc
index 014944da916..25deacbcdd1 100644
--- a/source/blender/editors/util/ed_util_ops.cc
+++ b/source/blender/editors/util/ed_util_ops.cc
@@ -226,7 +226,7 @@ static int lib_id_fake_user_toggle_exec(bContext *C, wmOperator *op)
 
   ID *id = (ID *)idptr.data;
 
-  if ((id->lib != nullptr) || (ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) {
+  if (ID_IS_LINKED(id) || (ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) {
     BKE_report(op->reports, RPT_ERROR, "Data-block type does not support fake user");
     return OPERATOR_CANCELLED;
   }
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 0d42abdb363..672af019177 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1988,7 +1988,7 @@ extern const char *RE_engine_id_CYCLES;
    ((v3d == NULL) || (((1 << (base)->object->type) & (v3d)->object_type_exclude_select) == 0)) && \
    (((base)->flag & BASE_SELECTABLE) != 0))
 #define BASE_SELECTED(v3d, base) (BASE_VISIBLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0))
-#define BASE_EDITABLE(v3d, base) (BASE_VISIBLE(v3d, base) && ((base)->object->id.lib == NULL))
+#define BASE_EDITABLE(v3d, base) (BASE_VISIBLE(v3d, base) && !ID_IS_LINKED((base)->object))
 #define BASE_SELECTED_EDITABLE(v3d, base) \
   (BASE_EDITABLE(v3d, base) && (((base)->flag & BASE_SELECTED) != 0))



More information about the Bf-blender-cvs mailing list