[Bf-blender-cvs] [edb95b3fcbb] master: Cleanup: Use `ID_IS_LINKED` instead of direct `id.lib` pointer check.

Bastien Montagne noreply at git.blender.org
Thu Aug 26 15:02:21 CEST 2021


Commit: edb95b3fcbb907fe4b93fecf9e398f41113b3ee4
Author: Bastien Montagne
Date:   Thu Aug 26 15:01:14 2021 +0200
Branches: master
https://developer.blender.org/rBedb95b3fcbb907fe4b93fecf9e398f41113b3ee4

Cleanup: Use `ID_IS_LINKED` instead of direct `id.lib` pointer check.

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

M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/constraint.c
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/blenkernel/intern/lib_id.c
M	source/blender/blenkernel/intern/lib_id_delete.c
M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/blenkernel/intern/lib_query.c
M	source/blender/blenkernel/intern/modifier.c
M	source/blender/blenkernel/intern/nla.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenkernel/intern/shader_fx.c
M	source/blender/blenkernel/intern/undo_system.c
M	source/blender/blenloader/intern/blend_validate.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_view3d/view3d_gizmo_camera.c
M	source/blender/editors/undo/memfile_undo.c
M	source/blender/makesrna/intern/rna_access.c

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 981815f400a..16d269f9e26 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1991,7 +1991,7 @@ void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
     if (UNLIKELY(pchan->bone == NULL)) {
       rebuild = true;
     }
-    else if ((ob->id.lib == NULL) && arm->id.lib) {
+    else if (!ID_IS_LINKED(ob) && ID_IS_LINKED(arm)) {
       /* local pose selection copied to armature, bit hackish */
       pchan->bone->flag &= ~BONE_SELECTED;
       pchan->bone->flag |= pchan->selectflag;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 30aa22387d0..72f14d94833 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -6657,7 +6657,7 @@ void BKE_constraint_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *con
     BLO_read_id_address(reader, id->lib, &con->ipo); /* XXX deprecated - old animation system */
 
     /* If linking from a library, clear 'local' library override flag. */
-    if (id->lib != NULL) {
+    if (ID_IS_LINKED(id)) {
       con->flag &= ~CONSTRAINT_OVERRIDE_LIBRARY_LOCAL;
     }
   }
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 9062fd2d39c..a143645c2ee 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -208,7 +208,7 @@ void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)
   BKE_animdata_blend_read_data(reader, gpd->adt);
 
   /* Ensure full objectmode for linked grease pencil. */
-  if (gpd->id.lib != NULL) {
+  if (ID_IS_LINKED(gpd)) {
     gpd->flag &= ~GP_DATA_STROKE_PAINTMODE;
     gpd->flag &= ~GP_DATA_STROKE_EDITMODE;
     gpd->flag &= ~GP_DATA_STROKE_SCULPTMODE;
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index 4db527e5b42..eac6a05d33a 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -1025,7 +1025,7 @@ void BKE_gpencil_modifier_blend_read_lib(BlendLibReader *reader, Object *ob)
   BKE_gpencil_modifiers_foreach_ID_link(ob, BKE_object_modifiers_lib_link_common, reader);
 
   /* If linking from a library, clear 'local' library override flag. */
-  if (ob->id.lib != NULL) {
+  if (ID_IS_LINKED(ob)) {
     LISTBASE_FOREACH (GpencilModifierData *, mod, &ob->greasepencil_modifiers) {
       mod->flag &= ~eGpencilModifierFlag_OverrideLibrary_Local;
     }
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index aa458bc1b27..11e9053df43 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -970,7 +970,7 @@ void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb)
 {
   int lb_len = 0;
   LISTBASE_FOREACH (ID *, id, lb) {
-    if (id->lib == NULL) {
+    if (!ID_IS_LINKED(id)) {
       lb_len += 1;
     }
   }
@@ -983,7 +983,7 @@ void BKE_main_id_repair_duplicate_names_listbase(ListBase *lb)
   GSet *gset = BLI_gset_str_new_ex(__func__, lb_len);
   int i = 0;
   LISTBASE_FOREACH (ID *, id, lb) {
-    if (id->lib == NULL) {
+    if (!ID_IS_LINKED(id)) {
       id_array[i] = id;
       i++;
     }
@@ -1840,7 +1840,7 @@ static void library_make_local_copying_check(ID *id,
       from_id = ((Key *)from_id)->from;
     }
 
-    if (from_id->lib == NULL) {
+    if (!ID_IS_LINKED(from_id)) {
       /* Local user, early out to avoid some gset querying... */
       continue;
     }
@@ -2068,7 +2068,7 @@ void BKE_library_make_local(Main *bmain,
     ID *id = it->link;
 
     BLI_assert(id->newid != NULL);
-    BLI_assert(id->lib != NULL);
+    BLI_assert(ID_IS_LINKED(id));
 
     BKE_libblock_remap(bmain, id, id->newid, ID_REMAP_SKIP_INDIRECT_USAGE);
     if (old_to_new_ids) {
@@ -2103,7 +2103,7 @@ void BKE_library_make_local(Main *bmain,
       bool is_local = false, is_lib = false;
 
       /* Proxies only work when the proxified object is linked-in from a library. */
-      if (ob->proxy->id.lib == NULL) {
+      if (!ID_IS_LINKED(ob->proxy)) {
         CLOG_WARN(&LOG,
                   "proxy object %s will lose its link to %s, because the "
                   "proxified object is local.",
@@ -2221,7 +2221,7 @@ void BKE_id_full_name_get(char name[MAX_ID_FULL_NAME], const ID *id, char separa
 {
   strcpy(name, id->name + 2);
 
-  if (id->lib != NULL) {
+  if (ID_IS_LINKED(id)) {
     const size_t idname_len = strlen(id->name + 2);
     const size_t libname_len = strlen(id->lib->id.name + 2);
 
@@ -2274,7 +2274,7 @@ void BKE_id_full_name_ui_prefix_get(char name[MAX_ID_FULL_NAME_UI],
  */
 char *BKE_id_to_unique_string_key(const struct ID *id)
 {
-  if (id->lib == NULL) {
+  if (!ID_IS_LINKED(id)) {
     return BLI_strdup(id->name);
   }
 
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index 43afac5a376..79717fe5f48 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -219,7 +219,7 @@ void BKE_id_free_us(Main *bmain, void *idv) /* test users */
    *     Otherwise, there is no real way to get rid of an object anymore -
    *     better handling of this is TODO.
    */
-  if ((GS(id->name) == ID_OB) && (id->us == 1) && (id->lib == NULL)) {
+  if ((GS(id->name) == ID_OB) && (id->us == 1) && !ID_IS_LINKED(id)) {
     id_us_clear_real(id);
   }
 
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index 8083585b594..8c1e04838df 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -104,7 +104,7 @@ IDOverrideLibrary *BKE_lib_override_library_init(ID *local_id, ID *reference_id)
 {
   /* If reference_id is NULL, we are creating an override template for purely local data.
    * Else, reference *must* be linked data. */
-  BLI_assert(reference_id == NULL || reference_id->lib != NULL);
+  BLI_assert(reference_id == NULL || ID_IS_LINKED(reference_id));
   BLI_assert(local_id->override_library == NULL);
 
   ID *ancestor_id;
@@ -286,7 +286,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
                                             const bool do_tagged_remap)
 {
   BLI_assert(reference_id != NULL);
-  BLI_assert(reference_id->lib != NULL);
+  BLI_assert(ID_IS_LINKED(reference_id));
 
   ID *local_id = lib_override_library_create_from(bmain, reference_id, 0);
 
@@ -299,7 +299,7 @@ ID *BKE_lib_override_library_create_from_id(Main *bmain,
 
     ID *other_id;
     FOREACH_MAIN_ID_BEGIN (bmain, other_id) {
-      if ((other_id->tag & LIB_TAG_DOIT) != 0 && other_id->lib == NULL) {
+      if ((other_id->tag & LIB_TAG_DOIT) != 0 && !ID_IS_LINKED(other_id)) {
         /* Note that using ID_REMAP_SKIP_INDIRECT_USAGE below is superfluous, as we only remap
          * local IDs usages anyway. */
         BKE_libblock_relink_ex(bmain,
@@ -830,7 +830,7 @@ static void lib_override_library_create_post_process(Main *bmain,
   Collection *default_instantiating_collection = residual_storage;
   LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
     Object *ob_new = (Object *)ob->id.newid;
-    if (ob_new == NULL || ob_new->id.lib != NULL) {
+    if (ob_new == NULL || ID_IS_LINKED(ob_new)) {
       continue;
     }
 
@@ -1148,7 +1148,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
         /* We need to 'move back' newly created override into its proper library (since it was
          * duplicated from the reference ID with 'no main' option, it should currently be the same
          * as the reference ID one). */
-        BLI_assert(/*id_override_new->lib == NULL || */ id_override_new->lib == id->lib);
+        BLI_assert(/*!ID_IS_LINKED(id_override_new) || */ id_override_new->lib == id->lib);
         BLI_assert(id_override_old == NULL || id_override_old->lib == id_root->lib);
         id_override_new->lib = id_root->lib;
         /* Remap step below will tag directly linked ones properly as needed. */
@@ -1734,8 +1734,7 @@ void BKE_lib_override_library_main_resync(Main *bmain,
 #define OVERRIDE_RESYNC_RESIDUAL_STORAGE_NAME "OVERRIDE_RESYNC_LEFTOVERS"
   Collection *override_resync_residual_storage = BLI_findstring(
       &bmain->collections, OVERRIDE_RESYNC_RESIDUAL_STORAGE_NAME, offsetof(ID, name) + 2);
-  if (override_resync_residual_storage != NULL &&
-      override_resync_residual_storage->id.lib != NULL) {
+  if (override_resync_residual_storage != NULL && ID_IS_LINKED(override_resync_residual_storage)) {
     override_resync_residual_storage = NULL;
   }
   if (override_resync_residual_storage == NULL) {
@@ -2195,7 +2194,7 @@ void BKE_lib_override_library_validate(Main *UNUSED(bmain), ID *id, ReportList *
     id->override_library->reference = NULL;
     return;
   }
-  if (id->override_library->reference->lib == NULL) {
+  if (!ID_IS_LINKED(id->override_library->reference)) {
     /* Very serious data corruption, cannot do much about it besides removing the reference
      * (therefore making the id a local override template one only). */
     BKE_reportf(reports,
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index 9400458376d..36cbf35b251 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -845,7 +845,7 @@ void BKE_library_indirectly_used_data_tag_clear(Main *bmain)
 
     while (i--) {
       LISTBASE_FOREACH (ID *, id, lb_array[i]) {
-        if (id->lib == NULL || id->tag & LIB_TAG_DOIT) {
+        if (!ID_IS_LINKED(id) || id->tag & LIB_TAG_DOIT) {
           /* Local or non-indirectly-used ID (so far), no need to check it further. */
           continue;
         }
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 821ca7b98b3..b328a31cda5 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/bl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list