Cleanup: Use ID_IS_LINKED
instead of direct id.lib
pointer check.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
|
||||
int i = set_listbasepointers(bmain, lbarray);
|
||||
while (i--) {
|
||||
for (ID *id = lbarray[i]->first; id != NULL; id = id->next) {
|
||||
if (id->lib != NULL) {
|
||||
if (ID_IS_LINKED(id)) {
|
||||
is_valid = false;
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
@@ -115,7 +115,7 @@ bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
|
||||
int totnames = 0;
|
||||
LinkNode *names = BLO_blendhandle_get_datablock_names(bh, GS(id->name), false, &totnames);
|
||||
for (; id != NULL; id = id->next) {
|
||||
if (id->lib == NULL) {
|
||||
if (!ID_IS_LINKED(id)) {
|
||||
is_valid = false;
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
@@ -179,7 +179,7 @@ bool BLO_main_validate_shapekeys(Main *bmain, ReportList *reports)
|
||||
if (!BKE_key_idtype_support(GS(id->name))) {
|
||||
break;
|
||||
}
|
||||
if (id->lib == NULL) {
|
||||
if (!ID_IS_LINKED(id)) {
|
||||
/* We assume lib data is valid... */
|
||||
Key *shapekey = BKE_key_from_id(id);
|
||||
if (shapekey != NULL && shapekey->from != id) {
|
||||
|
@@ -1625,7 +1625,7 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
|
||||
void blo_clear_proxy_pointers_from_lib(Main *oldmain)
|
||||
{
|
||||
LISTBASE_FOREACH (Object *, ob, &oldmain->objects) {
|
||||
if (ob->id.lib != NULL && ob->proxy_from != NULL && ob->proxy_from->id.lib == NULL) {
|
||||
if (ID_IS_LINKED(ob) && ob->proxy_from != NULL && !ID_IS_LINKED(ob->proxy_from)) {
|
||||
ob->proxy_from = NULL;
|
||||
}
|
||||
}
|
||||
|
@@ -444,7 +444,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
|
||||
|
||||
Collection *collection = BKE_collection_add(bmain, collection_master, name);
|
||||
collection->id.lib = scene->id.lib;
|
||||
if (collection->id.lib != NULL) {
|
||||
if (ID_IS_LINKED(collection)) {
|
||||
collection->id.tag |= LIB_TAG_INDIRECT;
|
||||
}
|
||||
collections[layer] = collection;
|
||||
@@ -574,10 +574,10 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene)
|
||||
|
||||
static void do_version_collection_propagate_lib_to_children(Collection *collection)
|
||||
{
|
||||
if (collection->id.lib != NULL) {
|
||||
if (ID_IS_LINKED(collection)) {
|
||||
for (CollectionChild *collection_child = collection->children.first; collection_child != NULL;
|
||||
collection_child = collection_child->next) {
|
||||
if (collection_child->collection->id.lib == NULL) {
|
||||
if (!ID_IS_LINKED(collection_child->collection)) {
|
||||
collection_child->collection->id.lib = collection->id.lib;
|
||||
}
|
||||
do_version_collection_propagate_lib_to_children(collection_child->collection);
|
||||
|
@@ -840,7 +840,7 @@ static void write_renderinfo(WriteData *wd, Main *mainvar)
|
||||
current_screen_compat(mainvar, false, &curscreen, &curscene, &view_layer);
|
||||
|
||||
LISTBASE_FOREACH (Scene *, sce, &mainvar->scenes) {
|
||||
if (sce->id.lib == NULL && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
|
||||
if (!ID_IS_LINKED(sce) && (sce == curscene || (sce->r.scemode & R_BG_RENDER))) {
|
||||
RenderInfo data;
|
||||
data.sfra = sce->r.sfra;
|
||||
data.efra = sce->r.efra;
|
||||
|
@@ -397,7 +397,7 @@ static bool id_search_add(const bContext *C, TemplateID *template_ui, uiSearchIt
|
||||
char name_ui[MAX_ID_FULL_NAME_UI];
|
||||
int iconid = ui_id_icon_get(C, id, template_ui->preview);
|
||||
const bool use_lib_prefix = template_ui->preview || iconid;
|
||||
const bool has_sep_char = (id->lib != NULL);
|
||||
const bool has_sep_char = ID_IS_LINKED(id);
|
||||
|
||||
/* When using previews, the library hint (linked, overridden, missing) is added with a
|
||||
* character prefix, otherwise we can use a icon. */
|
||||
@@ -1112,7 +1112,7 @@ static void template_ID(const bContext *C,
|
||||
UI_but_flag_enable(but, UI_BUT_REDALERT);
|
||||
}
|
||||
|
||||
if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS)) &&
|
||||
if (!ID_IS_LINKED(id) && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS)) &&
|
||||
(hide_buttons == false)) {
|
||||
uiDefIconButR(block,
|
||||
UI_BTYPE_ICON_TOGGLE,
|
||||
|
@@ -535,7 +535,7 @@ void ui_rna_collection_search_update_fn(const struct bContext *C,
|
||||
BLI_STATIC_ASSERT(sizeof(name_buf) >= MAX_ID_FULL_NAME_UI,
|
||||
"Name string buffer should be big enough to hold full UI ID name");
|
||||
name = name_buf;
|
||||
has_sep_char = (id->lib != NULL);
|
||||
has_sep_char = ID_IS_LINKED(id);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -3055,7 +3055,7 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist)
|
||||
ok = 1;
|
||||
if (ok) {
|
||||
if (!(filelist->filter_data.flags & FLF_HIDE_DOT) || id->name[2] != '.') {
|
||||
if (id->lib == NULL) {
|
||||
if (!ID_IS_LINKED(id)) {
|
||||
files->entry->relpath = BLI_strdup(id->name + 2);
|
||||
}
|
||||
else {
|
||||
|
@@ -2338,7 +2338,7 @@ int ED_image_save_all_modified_info(const Main *bmain, ReportList *reports)
|
||||
|
||||
if (image_should_be_saved(ima, &is_format_writable)) {
|
||||
if (BKE_image_has_packedfile(ima) || (ima->source == IMA_SRC_GENERATED)) {
|
||||
if (ima->id.lib == NULL) {
|
||||
if (!ID_IS_LINKED(ima)) {
|
||||
num_saveable_images++;
|
||||
}
|
||||
else {
|
||||
|
@@ -75,7 +75,7 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED(
|
||||
if (ob->type == OB_CAMERA) {
|
||||
Camera *camera = ob->data;
|
||||
/* TODO: support overrides. */
|
||||
if (camera->id.lib == NULL) {
|
||||
if (!ID_IS_LINKED(camera)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -408,7 +408,7 @@ static bool WIDGETGROUP_camera_view_poll(const bContext *C, wmGizmoGroupType *UN
|
||||
if (rv3d->persp == RV3D_CAMOB) {
|
||||
if (scene->r.mode & R_BORDER) {
|
||||
/* TODO: support overrides. */
|
||||
if (scene->id.lib == NULL) {
|
||||
if (!ID_IS_LINKED(scene)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -116,7 +116,7 @@ static int memfile_undosys_step_id_reused_cb(LibraryIDLinkCallbackData *cb_data)
|
||||
BLI_assert((id_self->tag & LIB_TAG_UNDO_OLD_ID_REUSED) != 0);
|
||||
|
||||
ID *id = *id_pointer;
|
||||
if (id != NULL && id->lib == NULL && (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) == 0) {
|
||||
if (id != NULL && !ID_IS_LINKED(id) && (id->tag & LIB_TAG_UNDO_OLD_ID_REUSED) == 0) {
|
||||
bool do_stop_iter = true;
|
||||
if (GS(id_self->name) == ID_OB) {
|
||||
Object *ob_self = (Object *)id_self;
|
||||
|
@@ -6151,7 +6151,7 @@ char *RNA_path_full_ID_py(Main *bmain, ID *id)
|
||||
}
|
||||
|
||||
char lib_filepath_esc[(sizeof(id->lib->filepath) * 2) + 4];
|
||||
if (id->lib != NULL) {
|
||||
if (ID_IS_LINKED(id)) {
|
||||
int ofs = 0;
|
||||
memcpy(lib_filepath_esc, ", \"", 3);
|
||||
ofs += 3;
|
||||
|
Reference in New Issue
Block a user