diff options
author | Bastien Montagne <bastien@blender.org> | 2021-08-26 16:01:14 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-08-26 16:01:14 +0300 |
commit | edb95b3fcbb907fe4b93fecf9e398f41113b3ee4 (patch) | |
tree | 0f39a4b935d29a170ecaa887496a0a0ef4cae72a /source/blender/blenkernel/intern | |
parent | 1bb2077250aed65e9445468161e01aa219a89624 (diff) |
Cleanup: Use `ID_IS_LINKED` instead of direct `id.lib` pointer check.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/action.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/constraint.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_modifier.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_delete.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.c | 15 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_query.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/nla.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shader_fx.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/undo_system.c | 2 |
14 files changed, 26 insertions, 27 deletions
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/blenkernel/intern/modifier.c @@ -1573,7 +1573,7 @@ void BKE_modifier_blend_read_lib(BlendLibReader *reader, Object *ob) BKE_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 (ModifierData *, mod, &ob->modifiers) { mod->flag &= ~eModifierFlag_OverrideLibrary_Local; } diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 7ea0d991f4c..4ce2ae3c11f 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -2344,7 +2344,7 @@ void BKE_nla_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *tracks) /* we only care about the NLA strips inside the tracks */ LISTBASE_FOREACH (NlaTrack *, nlt, tracks) { /* If linking from a library, clear 'local' library override flag. */ - if (id->lib != NULL) { + if (ID_IS_LINKED(id)) { nlt->flag &= ~NLATRACK_OVERRIDELIBRARY_LOCAL; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6e26ed4925d..c91cf6ed926 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -864,7 +864,7 @@ static void object_blend_read_lib(BlendLibReader *reader, ID *id) BLO_read_id_address(reader, ob->id.lib, &ob->proxy); if (ob->proxy) { /* paranoia check, actually a proxy_from pointer should never be written... */ - if (ob->proxy->id.lib == NULL) { + if (!ID_IS_LINKED(ob->proxy)) { ob->proxy->proxy_from = NULL; ob->proxy = NULL; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index de82f0832d8..6b5c94a2786 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -3356,7 +3356,7 @@ static char *scene_undo_depsgraph_gen_key(Scene *scene, ViewLayer *view_layer, c } size_t key_full_offset = BLI_strncpy_rlen(key_full, scene->id.name, MAX_ID_NAME); - if (scene->id.lib != NULL) { + if (ID_IS_LINKED(scene)) { key_full_offset += BLI_strncpy_rlen( key_full + key_full_offset, scene->id.lib->filepath, FILE_MAX); } diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c index 29cbe05f4d1..12017907038 100644 --- a/source/blender/blenkernel/intern/shader_fx.c +++ b/source/blender/blenkernel/intern/shader_fx.c @@ -326,7 +326,7 @@ void BKE_shaderfx_blend_read_lib(BlendLibReader *reader, Object *ob) BKE_shaderfx_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 (ShaderFxData *, fx, &ob->shader_fx) { fx->flag &= ~eShaderFxFlag_OverrideLibrary_Local; } diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index e524bd254bb..0ca2b97b4ef 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -145,7 +145,7 @@ static void undosys_id_ref_resolve(void *user_data, UndoRefID *id_ref) Main *bmain = user_data; ListBase *lb = which_libbase(bmain, GS(id_ref->name)); LISTBASE_FOREACH (ID *, id, lb) { - if (STREQ(id_ref->name, id->name) && (id->lib == NULL)) { + if (STREQ(id_ref->name, id->name) && !ID_IS_LINKED(id)) { id_ref->ptr = id; break; } |