diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-06 15:11:01 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-07-06 15:11:01 +0300 |
commit | d2312602125a452e6562a76ab91779943c67396d (patch) | |
tree | da74fa2bce05d94d6bc800021d837b494e6936d7 /source/blender/editors/object | |
parent | b98b331d04fe3a335cc0656809b4b09196507500 (diff) |
Replace of (id->lib != NULL) check by meaningful macro.
Idea is to replace hard-to-track (id->lib != NULL) 'is linked datablock' check everywhere in Blender
by a macro doing the same thing. This will allow to easily spot those checks in future, and more importantly,
to easily change it (see work done in asset-engine branch).
Note: did not touch to readfile.c, since there most of the time 'id->lib' check actually concerns the pointer,
and not a check whether ID is linked or not. Will have a closer look at it later.
Reviewers: campbellbarton, brecht, sergey
Differential Revision: https://developer.blender.org/D2082
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_constraint.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_data_transfer.c | 6 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 12 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 26 | ||||
-rw-r--r-- | source/blender/editors/object/object_shapekey.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_transform.c | 6 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 23 |
9 files changed, 50 insertions, 47 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 0f1c72fcd55..69950ccc9a9 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1162,7 +1162,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) Base *base_other; for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) { - if (scene_iter != scene && !(scene_iter->id.lib)) { + if (scene_iter != scene && !ID_IS_LINKED_DATABLOCK(scene_iter)) { base_other = BKE_scene_base_find(scene_iter, base->object); if (base_other) { if (is_indirectly_used && ID_REAL_USERS(base->object) <= 1) { @@ -1515,7 +1515,8 @@ static int convert_poll(bContext *C) Object *obact = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - return (!scene->id.lib && obact && scene->obedit != obact && (obact->flag & SELECT) && !(obact->id.lib)); + return (!ID_IS_LINKED_DATABLOCK(scene) && obact && scene->obedit != obact && + (obact->flag & SELECT) && !ID_IS_LINKED_DATABLOCK(obact)); } /* Helper for convert_exec */ @@ -2305,7 +2306,7 @@ static int join_poll(bContext *C) { Object *ob = CTX_data_active_object(C); - if (!ob || ob->id.lib) return 0; + if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE)) return ED_operator_screenactive(C); @@ -2358,7 +2359,7 @@ static int join_shapes_poll(bContext *C) { Object *ob = CTX_data_active_object(C); - if (!ob || ob->id.lib) return 0; + if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0; /* only meshes supported at the moment */ if (ob->type == OB_MESH) diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index d7b7fd7040e..db8a4c1960f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -584,7 +584,7 @@ static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type) return 0; } - if (ob->id.lib || (ptr.id.data && ((ID *)ptr.id.data)->lib)) { + if (ID_IS_LINKED_DATABLOCK(ob) || (ptr.id.data && ID_IS_LINKED_DATABLOCK(ptr.id.data))) { CTX_wm_operator_poll_msg_set(C, "Cannot edit library data"); return 0; } diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 47ee6752e51..acee69daab7 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -300,7 +300,7 @@ static void data_transfer_exec_preprocess_objects( } me = ob->data; - if (me->id.lib) { + if (ID_IS_LINKED_DATABLOCK(me)) { /* Do not transfer to linked data, not supported. */ BKE_reportf(op->reports, RPT_WARNING, "Skipping object '%s', linked data '%s' cannot be modified", ob->id.name + 2, me->id.name + 2); @@ -330,7 +330,7 @@ static bool data_transfer_exec_is_object_valid( me->id.tag &= ~LIB_TAG_DOIT; return true; } - else if (me->id.lib == NULL) { + else if (!ID_IS_LINKED_DATABLOCK(me)) { /* Do not transfer apply operation more than once. */ /* XXX This is not nice regarding vgroups, which are half-Object data... :/ */ BKE_reportf(op->reports, RPT_WARNING, @@ -387,7 +387,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - if (reverse_transfer && ((ID *)(ob_src->data))->lib) { + if (reverse_transfer && ID_IS_LINKED_DATABLOCK(ob_src->data)) { /* Do not transfer to linked data, not supported. */ return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 01a567931b3..3dc7d8ebd4b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -470,7 +470,7 @@ void ED_object_editmode_enter(bContext *C, int flag) View3D *v3d = NULL; bool ok = false; - if (scene->id.lib) return; + if (ID_IS_LINKED_DATABLOCK(scene)) return; if (sa && sa->spacetype == SPACE_VIEW3D) v3d = sa->spacedata.first; @@ -539,7 +539,7 @@ void ED_object_editmode_enter(bContext *C, int flag) * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ - if (arm->id.lib) { + if (ID_IS_LINKED_DATABLOCK(arm)) { error_libdata(); return; } @@ -621,7 +621,7 @@ static int editmode_toggle_poll(bContext *C) Object *ob = CTX_data_active_object(C); /* covers proxies too */ - if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) + if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED_DATABLOCK(ob->data)) return 0; /* if hidden but in edit mode, we still display */ @@ -848,7 +848,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Nurb *nu; bool do_depgraph_update = false; - if (scene->id.lib) return; + if (ID_IS_LINKED_DATABLOCK(scene)) return; if (!(ob = OBACT)) return; @@ -1436,7 +1436,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) { data = ob->data; - if (data && data->lib) { + if (data && ID_IS_LINKED_DATABLOCK(data)) { linked_data = true; continue; } @@ -1519,7 +1519,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) int a, b, done; if (scene->obedit) return; // XXX get from context - if (scene->id.lib) return; + if (ID_IS_LINKED_DATABLOCK(scene)) return; for (base = FIRSTBASE; base; base = base->next) { if (TESTBASELIB(v3d, base)) { diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 264945b00bf..b44ddf925a8 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -817,9 +817,9 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); - if (!ob || ob->id.lib) return 0; + if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0; if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; - if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0; + if (ptr.id.data && ID_IS_LINKED_DATABLOCK(ptr.id.data)) return 0; return 1; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 94d1a258063..9a6fe5ae48b 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -291,17 +291,17 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) Object *ob = ED_object_active_context(C); /* sanity checks */ - if (!scene || scene->id.lib || !ob) + if (!scene || ID_IS_LINKED_DATABLOCK(scene) || !ob) return OPERATOR_CANCELLED; /* Get object to work on - use a menu if we need to... */ - if (ob->dup_group && ob->dup_group->id.lib) { + if (ob->dup_group && ID_IS_LINKED_DATABLOCK(ob->dup_group)) { /* gives menu with list of objects in group */ /* proxy_group_objects_menu(C, op, ob, ob->dup_group); */ WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } - else if (ob->id.lib) { + else if (ID_IS_LINKED_DATABLOCK(ob)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); @@ -1466,7 +1466,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (scene_to->id.lib) { + if (ID_IS_LINKED_DATABLOCK(scene_to)) { BKE_report(op->reports, RPT_ERROR, "Cannot link objects into a linked scene"); return OPERATOR_CANCELLED; } @@ -1579,7 +1579,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) case MAKE_LINKS_ANIMDATA: BKE_animdata_copy_id((ID *)ob_dst, (ID *)ob_src, false); if (ob_dst->data && ob_src->data) { - if (obdata_id->lib) { + if (ID_IS_LINKED_DATABLOCK(obdata_id)) { is_lib = true; break; } @@ -1621,7 +1621,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) Curve *cu_src = ob_src->data; Curve *cu_dst = ob_dst->data; - if (obdata_id->lib) { + if (ID_IS_LINKED_DATABLOCK(obdata_id)) { is_lib = true; break; } @@ -1749,7 +1749,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in ob = base->object; if ((base->flag & flag) == flag) { - if (ob->id.lib == NULL && ob->id.us > 1) { + if (!ID_IS_LINKED_DATABLOCK(ob) && ob->id.us > 1) { /* base gets copy of object */ obn = BKE_object_copy(ob); base->object = obn; @@ -1828,7 +1828,7 @@ static void new_id_matar(Material **matar, const int totcol) for (a = 0; a < totcol; a++) { id = (ID *)matar[a]; - if (id && id->lib == NULL) { + if (id && !ID_IS_LINKED_DATABLOCK(id)) { if (id->newid) { matar[a] = (Material *)id->newid; id_us_plus(id->newid); @@ -1857,10 +1857,10 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag) for (base = FIRSTBASE; base; base = base->next) { ob = base->object; - if (ob->id.lib == NULL && (base->flag & flag) == flag) { + if (!ID_IS_LINKED_DATABLOCK(ob) && (base->flag & flag) == flag) { id = ob->data; - if (id && id->us > 1 && id->lib == NULL) { + if (id && id->us > 1 && !ID_IS_LINKED_DATABLOCK(id)) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); switch (ob->type) { @@ -1938,7 +1938,7 @@ static void single_object_action_users(Scene *scene, const int flag) for (base = FIRSTBASE; base; base = base->next) { ob = base->object; - if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { + if (!ID_IS_LINKED_DATABLOCK(ob) && (flag == 0 || (base->flag & SELECT)) ) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); BKE_animdata_copy_id_action(&ob->id); } @@ -1955,7 +1955,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture for (base = FIRSTBASE; base; base = base->next) { ob = base->object; - if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { + if (!ID_IS_LINKED_DATABLOCK(ob) && (flag == 0 || (base->flag & SELECT)) ) { for (a = 1; a <= ob->totcol; a++) { ma = give_current_material(ob, a); if (ma) { @@ -2184,7 +2184,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, Scene *scene) bool changed = false; for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->id.lib && (ob->id.us == 0)) { + if (ID_IS_LINKED_DATABLOCK(ob) && (ob->id.us == 0)) { Base *base; id_us_plus(&ob->id); diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 39bd34456be..e04114761e4 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -225,7 +225,7 @@ static int shape_key_mode_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT); + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) && ob->mode != OB_MODE_EDIT); } static int shape_key_mode_exists_poll(bContext *C) @@ -234,7 +234,7 @@ static int shape_key_mode_exists_poll(bContext *C) ID *data = (ob) ? ob->data : NULL; /* same as shape_key_mode_poll */ - return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) && + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) && ob->mode != OB_MODE_EDIT) && /* check a keyblock exists */ (BKE_keyblock_from_object(ob) != NULL); } @@ -246,14 +246,15 @@ static int shape_key_move_poll(bContext *C) ID *data = (ob) ? ob->data : NULL; Key *key = BKE_key_from_object(ob); - return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT && key && key->totkey > 1); + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) && + ob->mode != OB_MODE_EDIT && key && key->totkey > 1); } static int shape_key_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && data && !data->lib); + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data)); } static int shape_key_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index d2bbb73b597..6d80c4af292 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -391,7 +391,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l changed = false; } - if (obdata->lib) { + if (ID_IS_LINKED_DATABLOCK(obdata)) { BKE_reportf(reports, RPT_ERROR, "Cannot apply to library data: Object \"%s\", %s \"%s\", aborting", ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2); @@ -792,7 +792,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (ob->data == NULL) { /* special support for dupligroups */ if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) { - if (ob->dup_group->id.lib) { + if (ID_IS_LINKED_DATABLOCK(ob->dup_group)) { tot_lib_error++; } else { @@ -817,7 +817,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } } } - else if (((ID *)ob->data)->lib) { + else if (ID_IS_LINKED_DATABLOCK(ob->data)) { tot_lib_error++; } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 414cc476be5..6e8aaebcccc 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2447,8 +2447,8 @@ static int vertex_group_poll(bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && - data && !data->lib && + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && + data && !ID_IS_LINKED_DATABLOCK(data) && OB_TYPE_SUPPORT_VGROUP(ob->type) && ob->defbase.first); } @@ -2457,7 +2457,8 @@ static int vertex_group_supported_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib); + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && OB_TYPE_SUPPORT_VGROUP(ob->type) && + data && !ID_IS_LINKED_DATABLOCK(data)); } static int vertex_group_mesh_poll(bContext *C) @@ -2465,8 +2466,8 @@ static int vertex_group_mesh_poll(bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && - data && !data->lib && + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && + data && !ID_IS_LINKED_DATABLOCK(data) && ob->type == OB_MESH && ob->defbase.first); } @@ -2475,7 +2476,7 @@ static int UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib); + return (ob && !ID_IS_LINKED_DATABLOCK(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED_DATABLOCK(data)); } @@ -2484,7 +2485,7 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - if (!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data))) return 0; return BKE_object_is_in_editmode_vgroup(ob); @@ -2496,7 +2497,7 @@ static int vertex_group_vert_select_poll_ex(bContext *C, const short ob_type_fla Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - if (!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data))) return false; if (ob_type_flag && (((1 << ob->type) & ob_type_flag)) == 0) { @@ -2536,7 +2537,7 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - if (!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data))) return 0; if (!(BKE_object_is_in_editmode_vgroup(ob) || @@ -2559,7 +2560,7 @@ static int vertex_group_vert_select_mesh_poll(bContext *C) Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - if (!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data))) return 0; /* only difference to #vertex_group_vert_select_poll */ @@ -2748,7 +2749,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - if (!ob || ob->id.lib) + if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return OPERATOR_CANCELLED; vgroup_select_verts(ob, 1); |