diff options
author | Bastien Montagne <bastien@blender.org> | 2022-03-28 18:34:36 +0300 |
---|---|---|
committer | Fabian Schempp <fabianschempp@googlemail.com> | 2022-04-11 01:31:50 +0300 |
commit | a46de41db595de4c2564af25a091a420723a222f (patch) | |
tree | 4a90a688d8ff02c4d180aa7f16757f16b9236502 | |
parent | 59975875f892f004330e4df85ed8dec4a8036778 (diff) |
LibOverride: Massive edits to 'editable' IDs checks in editors code.
Add new `BKE_id_is_editable` helper in `BKE_lib_id.h`, that supercedes
previous check (simple `ID_IS_LINKED()` macro) for many editing cases.
This allows to also take into account 'system override' (aka
non-editable override) case.
Ref: {T95707}.
45 files changed, 195 insertions, 118 deletions
diff --git a/source/blender/blenkernel/BKE_lib_id.h b/source/blender/blenkernel/BKE_lib_id.h index c3122758a72..b81c8ef136f 100644 --- a/source/blender/blenkernel/BKE_lib_id.h +++ b/source/blender/blenkernel/BKE_lib_id.h @@ -594,6 +594,16 @@ bool BKE_id_is_in_global_main(struct ID *id); bool BKE_id_can_be_asset(const struct ID *id); +/** Check if that ID can be considered as editable from a high-level (editor) perspective. + * + * NOTE: This used to be done with a check on whether ID was linked or not, but now with system + * overrides this is not enough anymore. + * + * NOTE: Execution of this function can be somewhat expensive currently. If this becomes an issue, + * we should either cache that status info also in virtual override IDs, or address the + * long-standing TODO of geting an efficient 'owner_id' access for all embeded ID types. */ +bool BKE_id_is_editable(struct Main *bmain, struct ID *id); + /** * Returns ordered list of data-blocks for display in the UI. * Result is list of #LinkData of IDs that must be freed. diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 28745f1d2c7..27427b1fb44 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -2165,6 +2165,11 @@ bool BKE_id_can_be_asset(const ID *id) BKE_idtype_idcode_is_linkable(GS(id->name)); } +bool BKE_id_is_editable(Main *bmain, ID *id) +{ + return !(ID_IS_LINKED(id) || BKE_lib_override_library_is_system_defined(bmain, id)); +} + /************************* Datablock order in UI **************************/ static int *id_order_get(ID *id) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 5169d6904f5..ed0befbcc24 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -5117,8 +5117,9 @@ static void draw_setting_widget(bAnimContext *ac, break; } - if ((ale->fcurve_owner_id != NULL && ID_IS_LINKED(ale->fcurve_owner_id)) || - (ale->id != NULL && ID_IS_LINKED(ale->id))) { + if ((ale->fcurve_owner_id != NULL && + (ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) || + (ale->id != NULL && (ID_IS_LINKED(ale->id) || ID_IS_OVERRIDE_LIBRARY(ale->id)))) { if (setting != ACHANNEL_SETTING_EXPAND) { UI_but_flag_enable(but, UI_BUT_DISABLED); } diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 08379be36fa..31d90c8bfec 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2789,8 +2789,9 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) } /* don't allow renaming linked channels */ - if ((ale->fcurve_owner_id != NULL && ID_IS_LINKED(ale->fcurve_owner_id)) || - (ale->id != NULL && ID_IS_LINKED(ale->id))) { + if ((ale->fcurve_owner_id != NULL && + (ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) || + (ale->id != NULL && (ID_IS_LINKED(ale->id) || ID_IS_OVERRIDE_LIBRARY(ale->id)))) { ANIM_animdata_freelist(&anim_data); return false; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 0389e57627a..a75944fa2f2 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1462,7 +1462,7 @@ static size_t animfilter_action(bAnimContext *ac, /* don't include anything from this action if it is linked in from another file, * and we're getting stuff for editing... */ - if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act)) { + if ((filter_mode & ANIMFILTER_FOREDIT) && (ID_IS_LINKED(act) || ID_IS_OVERRIDE_LIBRARY(act))) { return 0; } diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index f40c1b983d7..58d093c678d 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -659,7 +659,8 @@ void draw_fcurve_channel(AnimKeylistDrawList *draw_list, { const bool locked = (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || - ((adt && adt->action) && ID_IS_LINKED(adt->action)); + ((adt && adt->action) && + (ID_IS_LINKED(adt->action) || ID_IS_OVERRIDE_LIBRARY(adt->action))); AnimKeylistDrawListElem *draw_elem = ed_keylist_draw_list_add_elem( draw_list, ANIM_KEYLIST_FCURVE, ypos, yscale_fac, saction_flag); @@ -676,7 +677,8 @@ void draw_agroup_channel(AnimKeylistDrawList *draw_list, int saction_flag) { bool locked = (agrp->flag & AGRP_PROTECTED) || - ((adt && adt->action) && ID_IS_LINKED(adt->action)); + ((adt && adt->action) && + (ID_IS_LINKED(adt->action) || ID_IS_OVERRIDE_LIBRARY(adt->action))); AnimKeylistDrawListElem *draw_elem = ed_keylist_draw_list_add_elem( draw_list, ANIM_KEYLIST_AGROUP, ypos, yscale_fac, saction_flag); @@ -692,7 +694,7 @@ void draw_action_channel(AnimKeylistDrawList *draw_list, float yscale_fac, int saction_flag) { - const bool locked = (act && ID_IS_LINKED(act)); + const bool locked = (act && (ID_IS_LINKED(act) || ID_IS_OVERRIDE_LIBRARY(act))); saction_flag &= ~SACTION_SHOW_EXTREMES; AnimKeylistDrawListElem *draw_elem = ed_keylist_draw_list_add_elem( diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 90ee7c83436..2ad7a373012 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -23,6 +23,7 @@ #include "BKE_deform.h" #include "BKE_global.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -78,7 +79,7 @@ Object *ED_pose_object_from_context(bContext *C) bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob) { - BLI_assert(!ID_IS_LINKED(ob)); + BLI_assert(BKE_id_is_editable(bmain, &ob->id)); bool ok = false; switch (ob->type) { @@ -99,11 +100,11 @@ bool ED_object_posemode_enter_ex(struct Main *bmain, Object *ob) bool ED_object_posemode_enter(bContext *C, Object *ob) { ReportList *reports = CTX_wm_reports(C); - if (ID_IS_LINKED(ob)) { + struct Main *bmain = CTX_data_main(C); + if (!BKE_id_is_editable(bmain, &ob->id)) { BKE_report(reports, RPT_WARNING, "Cannot pose libdata"); return false; } - struct Main *bmain = CTX_data_main(C); bool ok = ED_object_posemode_enter_ex(bmain, ob); if (ok) { WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL); diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 9796f6771d2..4b3ece64bf9 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -170,7 +170,7 @@ static bool has_poselib_pose_data_poll(bContext *C) static bool has_poselib_pose_data_for_editing_poll(bContext *C) { Object *ob = get_poselib_object(C); - return (ob && ob->poselib && !ID_IS_LINKED(ob->poselib)); + return (ob && ob->poselib && BKE_id_is_editable(CTX_data_main(C), &ob->poselib->id)); } /* ----------------------------------- */ @@ -377,7 +377,7 @@ static bool poselib_add_poll(bContext *C) if (ED_operator_posemode(C)) { Object *ob = get_poselib_object(C); if (ob) { - if ((ob->poselib == NULL) || !ID_IS_LINKED(ob->poselib)) { + if ((ob->poselib == NULL) || BKE_id_is_editable(CTX_data_main(C), &ob->poselib->id)) { return true; } } diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c index ced99f16794..9ee289145c4 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.c @@ -103,7 +103,8 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) } AnimData *adt = BKE_animdata_from_id(&pbd->ob->id); - if (adt != NULL && adt->action != NULL && ID_IS_LINKED(&adt->action->id)) { + if (adt != NULL && adt->action != NULL && + !BKE_id_is_editable(CTX_data_main(C), &adt->action->id)) { /* Changes to linked-in Actions are not allowed. */ return; } diff --git a/source/blender/editors/geometry/geometry_attributes.cc b/source/blender/editors/geometry/geometry_attributes.cc index 6225a68f53c..5d9d02db660 100644 --- a/source/blender/editors/geometry/geometry_attributes.cc +++ b/source/blender/editors/geometry/geometry_attributes.cc @@ -15,6 +15,7 @@ #include "BKE_context.h" #include "BKE_deform.h" #include "BKE_geometry_set.hh" +#include "BKE_lib_id.h" #include "BKE_object_deform.h" #include "BKE_report.h" @@ -41,8 +42,9 @@ namespace blender::ed::geometry { static bool geometry_attributes_poll(bContext *C) { Object *ob = ED_object_context(C); + Main *bmain = CTX_data_main(C); ID *data = (ob) ? static_cast<ID *>(ob->data) : nullptr; - return (ob && !ID_IS_LINKED(ob) && data && !ID_IS_LINKED(data)) && + return (ob && BKE_id_is_editable(bmain, &ob->id) && data && BKE_id_is_editable(bmain, data)) && BKE_id_attributes_supported(data); } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 338a7c8a51d..6843c42d2d0 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -2195,8 +2195,9 @@ static bool gpencil_vertex_group_poll(bContext *C) Object *ob = CTX_data_active_object(C); if ((ob) && (ob->type == OB_GPENCIL)) { + Main *bmain = CTX_data_main(C); const bGPdata *gpd = (const bGPdata *)ob->data; - if (!ID_IS_LINKED(ob) && !ID_IS_LINKED(ob->data) && + if (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, ob->data) && !BLI_listbase_is_empty(&gpd->vertex_group_names)) { if (ELEM(ob->mode, OB_MODE_EDIT_GPENCIL, OB_MODE_SCULPT_GPENCIL)) { return true; @@ -2212,8 +2213,9 @@ static bool gpencil_vertex_group_weight_poll(bContext *C) Object *ob = CTX_data_active_object(C); if ((ob) && (ob->type == OB_GPENCIL)) { + Main *bmain = CTX_data_main(C); const bGPdata *gpd = (const bGPdata *)ob->data; - if (!ID_IS_LINKED(ob) && !ID_IS_LINKED(ob->data) && + if (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, ob->data) && !BLI_listbase_is_empty(&gpd->vertex_group_names)) { if (ob->mode == OB_MODE_WEIGHT_GPENCIL) { return true; diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index 4710bada8e0..56bc1a6d956 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -22,6 +22,7 @@ #include "BLI_string.h" #include "BKE_context.h" +#include "BKE_lib_id.h" #include "BKE_screen.h" #include "BKE_unit.h" @@ -88,7 +89,8 @@ static int depthdropper_init(bContext *C, wmOperator *op) RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d && rv3d->persp == RV3D_CAMOB) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->camera && v3d->camera->data && !ID_IS_LINKED(v3d->camera->data)) { + if (v3d->camera && v3d->camera->data && + BKE_id_is_editable(CTX_data_main(C), v3d->camera->data)) { Camera *camera = (Camera *)v3d->camera->data; RNA_pointer_create(&camera->id, &RNA_CameraDOFSettings, &camera->dof, &ddr->ptr); ddr->prop = RNA_struct_find_property(&ddr->ptr, "focus_distance"); @@ -348,7 +350,8 @@ static bool depthdropper_poll(bContext *C) RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d && rv3d->persp == RV3D_CAMOB) { View3D *v3d = CTX_wm_view3d(C); - if (v3d->camera && v3d->camera->data && !ID_IS_LINKED(v3d->camera->data)) { + if (v3d->camera && v3d->camera->data && + BKE_id_is_editable(CTX_data_main(C), v3d->camera->data)) { return true; } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 2181b652d16..1499742af54 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -4712,7 +4712,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) Object *ob = base_iter->object; if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (!ID_IS_LINKED(me)) { + if (BKE_id_is_editable(bmain, &me->id)) { BMesh *bm_old = NULL; bool changed = false; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index b99ff8296f3..630ef66504f 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -481,7 +481,8 @@ static bool layers_poll(bContext *C) { Object *ob = ED_object_context(C); ID *data = (ob) ? ob->data : NULL; - return (ob && !ID_IS_LINKED(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED(data)); + return (ob && !ID_IS_LINKED(ob) && !ID_IS_OVERRIDE_LIBRARY(ob) && ob->type == OB_MESH && data && + !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data)); } /*********************** Sculpt Vertex colors operators ************************/ @@ -867,7 +868,7 @@ static bool mesh_customdata_mask_clear_poll(bContext *C) return false; } - if (!ID_IS_LINKED(me)) { + if (!ID_IS_LINKED(me) && !ID_IS_OVERRIDE_LIBRARY(me)) { CustomData *data = GET_CD_DATA(me, vdata); if (CustomData_has_layer(data, CD_PAINT_MASK)) { return true; @@ -918,7 +919,7 @@ static int mesh_customdata_skin_state(bContext *C) if (ob && ob->type == OB_MESH) { Mesh *me = ob->data; - if (!ID_IS_LINKED(me)) { + if (!ID_IS_LINKED(me) && !ID_IS_OVERRIDE_LIBRARY(me)) { CustomData *data = GET_CD_DATA(me, vdata); return CustomData_has_layer(data, CD_MVERT_SKIN); } diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index b8ffaf87118..f681f49df90 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -1280,7 +1280,7 @@ static bool object_gpencil_add_poll(bContext *C) Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); - if ((scene == nullptr) || (ID_IS_LINKED(scene))) { + if ((scene == nullptr) || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene)) { return false; } @@ -2752,12 +2752,14 @@ static int object_convert_exec(bContext *C, wmOperator *op) * However, changing this is more design than bug-fix, not to mention convoluted code below, * so that will be for later. * But at the very least, do not do that with linked IDs! */ - if ((ID_IS_LINKED(ob) || (ob->data && ID_IS_LINKED(ob->data))) && !keep_original) { + if ((!BKE_id_is_editable(bmain, &ob->id) || + (ob->data && !BKE_id_is_editable(bmain, static_cast<ID *>(ob->data)))) && + !keep_original) { keep_original = true; - BKE_report( - op->reports, - RPT_INFO, - "Converting some linked object/object data, enforcing 'Keep Original' option to True"); + BKE_report(op->reports, + RPT_INFO, + "Converting some non-editable object/object data, enforcing 'Keep Original' " + "option to True"); } DEG_id_tag_update(&base->object->id, ID_RECALC_GEOMETRY); @@ -3631,7 +3633,7 @@ static int object_transform_to_mouse_exec(bContext *C, wmOperator *op) /* Don't transform a linked object. There's just nothing to do here in this case, so return * #OPERATOR_FINISHED. */ - if (ID_IS_LINKED(ob)) { + if (!BKE_id_is_editable(bmain, &ob->id)) { return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 3abf0d68eb3..6805c9144d6 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -319,11 +319,11 @@ static void data_transfer_exec_preprocess_objects(bContext *C, } me = ob->data; - if (ID_IS_LINKED(me)) { - /* Do not transfer to linked data, not supported. */ + if (ID_IS_LINKED(me) || ID_IS_OVERRIDE_LIBRARY(me)) { + /* Do not transfer to linked/override data, not supported. */ BKE_reportf(op->reports, RPT_WARNING, - "Skipping object '%s', linked data '%s' cannot be modified", + "Skipping object '%s', linked or override data '%s' cannot be modified", ob->id.name + 2, me->id.name + 2); me->id.tag &= ~LIB_TAG_DOIT; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 7cef3e1725b..cc8644285c0 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -51,6 +51,7 @@ #include "BKE_image.h" #include "BKE_lattice.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_mball.h" @@ -973,7 +974,7 @@ static int posemode_exec(bContext *C, wmOperator *op) const View3D *v3d = CTX_wm_view3d(C); FOREACH_SELECTED_OBJECT_BEGIN (view_layer, v3d, ob) { if ((ob != obact) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_OBJECT) && - (!ID_IS_LINKED(ob))) { + BKE_id_is_editable(bmain, &ob->id)) { ED_object_posemode_enter_ex(bmain, ob); } } @@ -1528,6 +1529,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) } } + Main *bmain = CTX_data_main(C); LISTBASE_FOREACH (CollectionPointerLink *, ctx_ob, &ctx_objects) { /* Always un-tag all object data-blocks irrespective of our ability to operate on them. */ Object *ob = ctx_ob->ptr.data; @@ -1538,7 +1540,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) data->tag &= ~LIB_TAG_DOIT; /* Finished un-tagging, continue with regular logic. */ - if (data && ID_IS_LINKED(data)) { + if (data && !BKE_id_is_editable(bmain, data)) { has_linked_data = true; continue; } diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index d0a6a5d44c0..573f048e6b6 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -26,6 +26,7 @@ #include "BKE_context.h" #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -418,17 +419,18 @@ static bool gpencil_edit_modifier_poll_generic(bContext *C, int obtype_flag, const bool is_liboverride_allowed) { + Main *bmain = CTX_data_main(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); GpencilModifierData *mod = ptr.data; /* May be NULL. */ - if (!ob || ID_IS_LINKED(ob)) { + if (!ob || !BKE_id_is_editable(bmain, &ob->id)) { return false; } if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) { return false; } - if (ptr.owner_id && ID_IS_LINKED(ptr.owner_id)) { + if (ptr.owner_id && !BKE_id_is_editable(bmain, ptr.owner_id)) { return false; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 7c3571d3b75..9039556ea93 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1016,6 +1016,7 @@ bool edit_modifier_poll_generic(bContext *C, const bool is_editmode_allowed, const bool is_liboverride_allowed) { + Main *bmain = CTX_data_main(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); ModifierData *mod = ptr.data; /* May be NULL. */ @@ -1024,13 +1025,13 @@ bool edit_modifier_poll_generic(bContext *C, mod = BKE_object_active_modifier(ob); } - if (!ob || ID_IS_LINKED(ob)) { + if (!ob || !BKE_id_is_editable(bmain, &ob->id)) { return false; } if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) { return false; } - if (ptr.owner_id && ID_IS_LINKED(ptr.owner_id)) { + if (ptr.owner_id && !BKE_id_is_editable(bmain, ptr.owner_id)) { return false; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 70081b4b5f2..064a84cdea5 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1350,7 +1350,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (ID_IS_LINKED(scene_to)) { + if (!BKE_id_is_editable(bmain, &scene_to->id)) { BKE_report(op->reports, RPT_ERROR, "Cannot link objects into a linked scene"); return OPERATOR_CANCELLED; } @@ -1481,7 +1481,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) case MAKE_LINKS_ANIMDATA: BKE_animdata_copy_id(bmain, (ID *)ob_dst, (ID *)ob_src, 0); if (ob_dst->data && ob_src->data) { - if (ID_IS_LINKED(obdata_id)) { + if (!BKE_id_is_editable(bmain, obdata_id)) { is_lib = true; break; } @@ -1525,7 +1525,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) Curve *cu_src = ob_src->data; Curve *cu_dst = ob_dst->data; - if (ID_IS_LINKED(obdata_id)) { + if (!BKE_id_is_editable(bmain, obdata_id)) { is_lib = true; break; } @@ -1792,7 +1792,7 @@ static void single_obdata_users( ID *id; FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { - if (!ID_IS_LINKED(ob)) { + if (BKE_id_is_editable(bmain, &ob->id)) { id = ob->data; if (single_data_needs_duplication(id)) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -1897,7 +1897,7 @@ static void single_object_action_users( Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag) { FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { - if (!ID_IS_LINKED(ob)) { + if (BKE_id_is_editable(bmain, &ob->id)) { AnimData *adt = BKE_animdata_from_id(&ob->id); if (adt == NULL) { continue; @@ -1917,7 +1917,7 @@ static void single_objectdata_action_users( Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag) { FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { - if (!ID_IS_LINKED(ob) && ob->data != NULL) { + if (BKE_id_is_editable(bmain, &ob->id) && ob->data != NULL) { ID *id_obdata = (ID *)ob->data; AnimData *adt = BKE_animdata_from_id(id_obdata); if (adt == NULL) { @@ -1941,7 +1941,7 @@ static void single_mat_users( int a; FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { - if (!ID_IS_LINKED(ob)) { + if (BKE_id_is_editable(bmain, &ob->id)) { for (a = 1; a <= ob->totcol; a++) { ma = BKE_object_material_get(ob, (short)a); if (single_data_needs_duplication(&ma->id)) { diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c index 973f4d4561d..dd7fc192dc1 100644 --- a/source/blender/editors/object/object_shader_fx.c +++ b/source/blender/editors/object/object_shader_fx.c @@ -25,6 +25,7 @@ #include "BLT_translation.h" #include "BKE_context.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_report.h" @@ -278,8 +279,8 @@ static bool edit_shaderfx_poll_generic(bContext *C, CTX_wm_operator_poll_msg_set(C, "Object type is not supported"); return false; } - if (ptr.owner_id != NULL && ID_IS_LINKED(ptr.owner_id)) { - CTX_wm_operator_poll_msg_set(C, "Cannot edit library data"); + if (ptr.owner_id != NULL && !BKE_id_is_editable(CTX_data_main(C), ptr.owner_id)) { + CTX_wm_operator_poll_msg_set(C, "Cannot edit library or override data"); return false; } if (!is_liboverride_allowed && BKE_shaderfx_is_nonlocal_in_liboverride(ob, fx)) { diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index afd2c048379..da75703a0d9 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -622,10 +622,10 @@ static int apply_objects_internal(bContext *C, changed = false; } - if (ID_IS_LINKED(obdata)) { + if (ID_IS_LINKED(obdata) || ID_IS_OVERRIDE_LIBRARY(obdata)) { BKE_reportf(reports, RPT_ERROR, - R"(Cannot apply to library data: Object "%s", %s "%s", aborting)", + R"(Cannot apply to library or override data: Object "%s", %s "%s", aborting)", ob->id.name + 2, BKE_idtype_idcode_to_name(GS(obdata->name)), obdata->name + 2); @@ -1138,7 +1138,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* Special support for instanced collections. */ if ((ob->transflag & OB_DUPLICOLLECTION) && ob->instance_collection && (ob->instance_collection->id.tag & LIB_TAG_DOIT) == 0) { - if (ID_IS_LINKED(ob->instance_collection)) { + if (!BKE_id_is_editable(bmain, &ob->instance_collection->id)) { tot_lib_error++; } else { @@ -1163,7 +1163,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } } } - else if (ID_IS_LINKED(ob->data)) { + else if (ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { tot_lib_error++; } else if (ob->type == OB_MESH) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index f0fa693bd85..a58ffa4e0a6 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -3062,7 +3062,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - if (!ob || ID_IS_LINKED(ob)) { + if (!ob || ID_IS_LINKED(ob) || ID_IS_OVERRIDE_LIBRARY(ob)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 4a639e227f7..eba647a1b17 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -5406,10 +5406,10 @@ static bool particle_edit_toggle_poll(bContext *C) Object *ob = CTX_data_active_object(C); if (ob == NULL || ob->type != OB_MESH) { - return 0; + return false; } - if (!ob->data || ID_IS_LINKED(ob->data)) { - return 0; + if (!ob->data || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { + return false; } return ED_object_particle_edit_mode_supported(ob); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 24860b9c4d8..6bea6e2c19e 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -1048,7 +1048,7 @@ static void remove_particle_systems_from_object(Object *ob_to) if (ob_to->type != OB_MESH) { return; } - if (!ob_to->data || ID_IS_LINKED(ob_to->data)) { + if (!ob_to->data || ID_IS_LINKED(ob_to->data) || ID_IS_OVERRIDE_LIBRARY(ob_to->data)) { return; } @@ -1090,7 +1090,7 @@ static bool copy_particle_systems_to_object(const bContext *C, if (ob_to->type != OB_MESH) { return false; } - if (!ob_to->data || ID_IS_LINKED(ob_to->data)) { + if (!ob_to->data || !BKE_id_is_editable(bmain, ob_to->data)) { return false; } diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index eb799f46177..66ae2d323fd 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -40,12 +40,21 @@ /* ********************************************** */ /* Helper API's for RigidBody Constraint Editing */ +static bool operator_rigidbody_constraints_editable_poll(Scene *scene) +{ + if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && + (ID_IS_LINKED(scene->rigidbody_world->constraints) || + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->constraints)))) { + return false; + } + return true; +} + static bool ED_operator_rigidbody_con_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && - ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + if (!operator_rigidbody_constraints_editable_poll(scene)) { return false; } @@ -59,9 +68,7 @@ static bool ED_operator_rigidbody_con_active_poll(bContext *C) static bool ED_operator_rigidbody_con_add_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->constraints != NULL && - ID_IS_LINKED(&scene->rigidbody_world->constraints->id))) { + if (!operator_rigidbody_constraints_editable_poll(scene)) { return false; } return ED_operator_object_active_editable(C); diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 8f69947ceb0..5ff687bce1a 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -44,12 +44,21 @@ /* ********************************************** */ /* Helper API's for RigidBody Objects Editing */ +static bool operator_rigidbody_editable_poll(Scene *scene) +{ + if (scene == NULL || ID_IS_LINKED(scene) || ID_IS_OVERRIDE_LIBRARY(scene) || + (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && + (ID_IS_LINKED(scene->rigidbody_world->group) || + ID_IS_OVERRIDE_LIBRARY(scene->rigidbody_world->group)))) { + return false; + } + return true; +} + static bool ED_operator_rigidbody_active_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && - ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + if (!operator_rigidbody_editable_poll(scene)) { return false; } @@ -57,15 +66,14 @@ static bool ED_operator_rigidbody_active_poll(bContext *C) Object *ob = ED_object_active_context(C); return (ob && ob->rigidbody_object); } - return 0; + + return false; } static bool ED_operator_rigidbody_add_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL || ID_IS_LINKED(&scene->id) || - (scene->rigidbody_world != NULL && scene->rigidbody_world->group != NULL && - ID_IS_LINKED(&scene->rigidbody_world->group->id))) { + if (!operator_rigidbody_editable_poll(scene)) { return false; } @@ -73,6 +81,7 @@ static bool ED_operator_rigidbody_add_poll(bContext *C) Object *ob = ED_object_active_context(C); return (ob && ob->type == OB_MESH); } + return false; } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index d3cb6942892..408ddfe7241 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -177,10 +177,10 @@ bool ED_operator_scene(bContext *C) bool ED_operator_scene_editable(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene && !ID_IS_LINKED(scene)) { - return true; + if (scene == NULL || !BKE_id_is_editable(CTX_data_main(C), &scene->id)) { + return false; } - return false; + return true; } bool ED_operator_objectmode(bContext *C) @@ -319,7 +319,7 @@ bool ED_operator_node_editable(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree)) { + if (snode && snode->edittree && BKE_id_is_editable(CTX_data_main(C), &snode->edittree->id)) { return true; } @@ -380,8 +380,8 @@ bool ED_operator_object_active_editable_ex(bContext *C, const Object *ob) return false; } - if (ID_IS_LINKED(ob)) { - CTX_wm_operator_poll_msg_set(C, "Cannot edit library linked object"); + if (!BKE_id_is_editable(CTX_data_main(C), (ID *)ob)) { + CTX_wm_operator_poll_msg_set(C, "Cannot edit library linked or non-editable override object"); return false; } @@ -546,9 +546,10 @@ bool ED_operator_posemode(bContext *C) bool ED_operator_posemode_local(bContext *C) { if (ED_operator_posemode(C)) { + Main *bmain = CTX_data_main(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm = ob->data; - return !(ID_IS_LINKED(&ob->id) || ID_IS_LINKED(&arm->id)); + return (BKE_id_is_editable(bmain, &ob->id) && BKE_id_is_editable(bmain, &arm->id)); } return false; } diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 0c73c2e1f43..572e5b78b74 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -272,7 +272,8 @@ static bool image_paint_poll_ex(bContext *C, bool check_tool) SpaceImage *sima = CTX_wm_space_image(C); if (sima) { - if (sima->image != nullptr && ID_IS_LINKED(sima->image)) { + if (sima->image != nullptr && + (ID_IS_LINKED(sima->image) || ID_IS_OVERRIDE_LIBRARY(sima->image))) { return false; } ARegion *region = CTX_wm_region(C); @@ -850,7 +851,7 @@ static bool texture_paint_toggle_poll(bContext *C) if (ob == nullptr || ob->type != OB_MESH) { return false; } - if (!ob->data || ID_IS_LINKED(ob->data)) { + if (ob->data == nullptr || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { return false; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 12215083eb6..233cfc3b33d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -6332,7 +6332,7 @@ bool ED_paint_proj_mesh_data_check( for (int i = 1; i < ob->totcol + 1; i++) { Material *ma = BKE_object_material_get(ob, i); - if (ma && !ID_IS_LINKED(ma)) { + if (ma && !ID_IS_LINKED(ma) && !ID_IS_OVERRIDE_LIBRARY(ma)) { hasmat = true; if (ma->texpaintslot == NULL) { /* refresh here just in case */ @@ -6340,7 +6340,8 @@ bool ED_paint_proj_mesh_data_check( } if (ma->texpaintslot != NULL && (ma->texpaintslot[ma->paint_active_slot].ima == NULL || - !ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima))) { + !ID_IS_LINKED(ma->texpaintslot[ma->paint_active_slot].ima) || + !ID_IS_OVERRIDE_LIBRARY(ma->texpaintslot[ma->paint_active_slot].ima))) { hastex = true; break; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index e2f8d81fe13..c4d80d38100 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1404,7 +1404,7 @@ static bool paint_mode_toggle_poll_test(bContext *C) if (ob == NULL || ob->type != OB_MESH) { return false; } - if (!ob->data || ID_IS_LINKED(ob->data)) { + if (!ob->data || ID_IS_LINKED(ob->data) || ID_IS_OVERRIDE_LIBRARY(ob->data)) { return false; } return true; diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 53e8649585a..cd174681ccb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -616,7 +616,7 @@ static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op)) ID *data; data = ob->data; - if (data && ID_IS_LINKED(data)) { + if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) { return OPERATOR_CANCELLED; } @@ -681,7 +681,7 @@ static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op)) ID *data; data = ob->data; - if (data && ID_IS_LINKED(data)) { + if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc index a4ff44512ef..8ca2ffe6a9c 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -354,7 +354,7 @@ void outliner_collection_delete( else { LISTBASE_FOREACH (CollectionParent *, cparent, &collection->parents) { Collection *parent = cparent->collection; - if (ID_IS_LINKED(parent)) { + if (ID_IS_LINKED(parent) || ID_IS_OVERRIDE_LIBRARY(parent)) { skip = true; break; } @@ -366,7 +366,7 @@ void outliner_collection_delete( ID *scene_owner = id_type->owner_get(bmain, &parent->id); BLI_assert(GS(scene_owner->name) == ID_SCE); - if (ID_IS_LINKED(scene_owner)) { + if (ID_IS_LINKED(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) { skip = true; break; } @@ -603,7 +603,9 @@ static int collection_duplicate_exec(bContext *C, wmOperator *op) if (ID_IS_LINKED(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) { scene_owner = CTX_data_scene(C); - parent = ID_IS_LINKED(scene_owner) ? nullptr : scene_owner->master_collection; + parent = (ID_IS_LINKED(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) ? + nullptr : + scene_owner->master_collection; } } @@ -1293,6 +1295,7 @@ static bool collection_disable_render_poll(bContext *C) static int collection_flag_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); SpaceOutliner *space_outliner = CTX_wm_space_outliner(C); @@ -1319,7 +1322,7 @@ static int collection_flag_exec(bContext *C, wmOperator *op) LayerCollection *layer_collection = reinterpret_cast<LayerCollection *>( BLI_gsetIterator_getKey(&collections_to_edit_iter)); Collection *collection = layer_collection->collection; - if (ID_IS_LINKED(collection)) { + if (!BKE_id_is_editable(bmain, &collection->id)) { continue; } if (clear) { @@ -1347,7 +1350,7 @@ static int collection_flag_exec(bContext *C, wmOperator *op) GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { Collection *collection = reinterpret_cast<Collection *>( BLI_gsetIterator_getKey(&collections_to_edit_iter)); - if (ID_IS_LINKED(collection)) { + if (!BKE_id_is_editable(bmain, &collection->id)) { continue; } @@ -1600,7 +1603,7 @@ static int outliner_color_tag_set_exec(bContext *C, wmOperator *op) if (collection == scene->master_collection) { continue; } - if (ID_IS_LINKED(collection)) { + if (!BKE_id_is_editable(CTX_data_main(C), &collection->id)) { BKE_report(op->reports, RPT_WARNING, "Can't add a color tag to a linked collection"); continue; } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc index 30b81b2ecb2..88640210ea3 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.cc +++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc @@ -22,6 +22,7 @@ #include "BKE_collection.h" #include "BKE_context.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_object.h" @@ -374,7 +375,7 @@ static void parent_drop_set_parents(bContext *C, Object *object = (Object *)drag_id->id; /* Do nothing to linked data */ - if (ID_IS_LINKED(object)) { + if (!BKE_id_is_editable(bmain, &object->id)) { linked_objects = true; continue; } @@ -387,7 +388,7 @@ static void parent_drop_set_parents(bContext *C, } if (linked_objects) { - BKE_report(reports, RPT_INFO, "Can't edit library linked object(s)"); + BKE_report(reports, RPT_INFO, "Can't edit library linked or non-editable override object(s)"); } if (parent_set) { @@ -556,7 +557,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent Scene *scene = (Scene *)outliner_ID_drop_find(C, event, ID_SCE); Object *ob = (Object *)WM_drag_get_local_ID_from_event(event, ID_OB); - if (ELEM(nullptr, ob, scene) || ID_IS_LINKED(scene)) { + if (ELEM(nullptr, ob, scene) || !BKE_id_is_editable(bmain, &scene->id)) { return OPERATOR_CANCELLED; } @@ -748,7 +749,7 @@ static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData ob = nullptr; } - if (ob && ID_IS_LINKED(&ob->id)) { + if (ob && !BKE_id_is_editable(CTX_data_main(C), &ob->id)) { return false; } @@ -1107,8 +1108,8 @@ struct CollectionDrop { static Collection *collection_parent_from_ID(ID *id) { - /* Can't change linked parent collections. */ - if (!id || ID_IS_LINKED(id)) { + /* Can't change linked or override parent collections. */ + if (!id || ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY(id)) { return nullptr; } @@ -1134,7 +1135,7 @@ static bool collection_drop_init( } Collection *to_collection = outliner_collection_from_tree_element(te); - if (ID_IS_LINKED(to_collection)) { + if (ID_IS_LINKED(to_collection) || ID_IS_OVERRIDE_LIBRARY(to_collection)) { return false; } diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 9857abb3da7..a6f09a86eb4 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -2165,8 +2165,10 @@ static void outliner_draw_mode_column_toggle(uiBlock *block, /* Mode toggling handles its own undo state because undo steps need to be grouped. */ UI_but_flag_disable(but, UI_BUT_UNDO); - if (ID_IS_LINKED(&ob->id)) { - UI_but_disable(but, TIP_("Can't edit external library data")); + if (ID_IS_LINKED(&ob->id) || + (ID_IS_OVERRIDE_LIBRARY_REAL(ob) && + (ob->id.override_library->flag & IDOVERRIDE_LIBRARY_FLAG_SYSTEM_DEFINED) != 0)) { + UI_but_disable(but, TIP_("Can't edit library or non-editable override data")); } } diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index a202ded6deb..fd0ee422df0 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -31,6 +31,7 @@ #include "BKE_gpencil.h" #include "BKE_gpencil_modifier.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -116,8 +117,8 @@ static void do_outliner_item_posemode_toggle(bContext *C, Scene *scene, Base *ba Main *bmain = CTX_data_main(C); Object *ob = base->object; - if (ID_IS_LINKED(ob)) { - BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose libdata"); + if (!BKE_id_is_editable(CTX_data_main(C), &ob->id)) { + BKE_report(CTX_wm_reports(C), RPT_WARNING, "Cannot pose non-editable data"); return; } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index f5656e13c0e..49c0236866d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -185,7 +185,7 @@ static bool text_edit_poll(bContext *C) return false; } - if (ID_IS_LINKED(text)) { + if (!BKE_id_is_editable(CTX_data_main(C), &text->id)) { // BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data"); return false; } @@ -202,7 +202,7 @@ bool text_space_edit_poll(bContext *C) return false; } - if (ID_IS_LINKED(text)) { + if (!BKE_id_is_editable(CTX_data_main(C), &text->id)) { // BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data"); return false; } @@ -224,7 +224,7 @@ static bool text_region_edit_poll(bContext *C) return false; } - if (ID_IS_LINKED(text)) { + if (!BKE_id_is_editable(CTX_data_main(C), &text->id)) { // BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data"); return false; } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 4451d629a04..83f589a64c9 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -11,6 +11,7 @@ #include "BKE_camera.h" #include "BKE_context.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "DNA_camera_types.h" #include "DNA_object_types.h" @@ -61,7 +62,7 @@ static bool WIDGETGROUP_camera_poll(const bContext *C, wmGizmoGroupType *UNUSED( if (ob->type == OB_CAMERA) { Camera *camera = ob->data; /* TODO: support overrides. */ - if (!ID_IS_LINKED(camera)) { + if (BKE_id_is_editable(CTX_data_main(C), &camera->id)) { return true; } } @@ -384,7 +385,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 (!ID_IS_LINKED(scene)) { + if (BKE_id_is_editable(CTX_data_main(C), &scene->id)) { return true; } } diff --git a/source/blender/editors/space_view3d/view3d_navigate_fly.c b/source/blender/editors/space_view3d/view3d_navigate_fly.c index af78663fff9..5b817dc1f45 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_fly.c +++ b/source/blender/editors/space_view3d/view3d_navigate_fly.c @@ -24,6 +24,7 @@ #include "BLI_math.h" #include "BKE_context.h" +#include "BKE_lib_id.h" #include "BKE_report.h" #include "BLT_translation.h" @@ -321,8 +322,11 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->rv3d->persp = RV3D_PERSP; } - if (fly->rv3d->persp == RV3D_CAMOB && ID_IS_LINKED(fly->v3d->camera)) { - BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library"); + if (fly->rv3d->persp == RV3D_CAMOB && !BKE_id_is_editable(CTX_data_main(C), &fly->v3d->camera->id)) { + BKE_report(op->reports, + RPT_ERROR, + "Cannot navigate a camera from an external library or non-editable override"); + return false; } diff --git a/source/blender/editors/space_view3d/view3d_navigate_walk.c b/source/blender/editors/space_view3d/view3d_navigate_walk.c index 333c99c2fca..c842eba54b3 100644 --- a/source/blender/editors/space_view3d/view3d_navigate_walk.c +++ b/source/blender/editors/space_view3d/view3d_navigate_walk.c @@ -22,6 +22,7 @@ #include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_report.h" @@ -503,8 +504,10 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->persp = RV3D_PERSP; } - if (walk->rv3d->persp == RV3D_CAMOB && ID_IS_LINKED(walk->v3d->camera)) { - BKE_report(op->reports, RPT_ERROR, "Cannot navigate a camera from an external library"); + if (walk->rv3d->persp == RV3D_CAMOB && !BKE_id_is_editable(CTX_data_main(C), &walk->v3d->camera->id)) { + BKE_report(op->reports, + RPT_ERROR, + "Cannot navigate a camera from an external library or non-editable override"); return false; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index e7fcc401523..a56bbb1c1df 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -18,6 +18,7 @@ #include "BKE_gpencil_modifier.h" #include "BKE_idprop.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -84,7 +85,7 @@ static bool view3d_camera_to_view_poll(bContext *C) if (ED_view3d_context_user_region(C, &v3d, ®ion)) { RegionView3D *rv3d = region->regiondata; - if (v3d && v3d->camera && !ID_IS_LINKED(v3d->camera)) { + if (v3d && v3d->camera && BKE_id_is_editable(CTX_data_main(C), &v3d->camera->id)) { if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) { if (rv3d->persp != RV3D_CAMOB) { return true; diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c index 1d187d01588..d2585493679 100644 --- a/source/blender/editors/transform/transform_convert_object.c +++ b/source/blender/editors/transform/transform_convert_object.c @@ -13,6 +13,7 @@ #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_layer.h" +#include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_object.h" #include "BKE_pointcache.h" @@ -481,6 +482,7 @@ static void clear_trans_object_base_flags(TransInfo *t) void createTransObject(bContext *C, TransInfo *t) { + Main *bmain = CTX_data_main(C); TransData *td = NULL; TransDataExtension *tx; const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; @@ -527,7 +529,7 @@ void createTransObject(bContext *C, TransInfo *t) } /* select linked objects, but skip them later */ - if (ID_IS_LINKED(ob)) { + if (!BKE_id_is_editable(bmain, &ob->id)) { td->flag |= TD_SKIP; } diff --git a/source/blender/editors/transform/transform_convert_sculpt.c b/source/blender/editors/transform/transform_convert_sculpt.c index 0c6214668ba..5bf6bfa8644 100644 --- a/source/blender/editors/transform/transform_convert_sculpt.c +++ b/source/blender/editors/transform/transform_convert_sculpt.c @@ -10,6 +10,7 @@ #include "BLI_math.h" #include "BKE_context.h" +#include "BKE_lib_id.h" #include "BKE_paint.h" #include "BKE_report.h" @@ -27,7 +28,7 @@ void createTransSculpt(bContext *C, TransInfo *t) TransData *td; Scene *scene = t->scene; - if (ID_IS_LINKED(scene)) { + if (!BKE_id_is_editable(CTX_data_main(C), &scene->id)) { BKE_report(t->reports, RPT_ERROR, "Linked data can't text-space transform"); return; } @@ -102,7 +103,7 @@ void recalcData_sculpt(TransInfo *t) void special_aftertrans_update__sculpt(bContext *C, TransInfo *t) { Scene *scene = t->scene; - if (ID_IS_LINKED(scene)) { + if (!BKE_id_is_editable(CTX_data_main(C), &scene->id)) { /* `ED_sculpt_init_transform` was not called in this case. */ return; } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 32d405df841..f125482460c 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -19,6 +19,7 @@ #include "BKE_collection.h" #include "BKE_global.h" +#include "BKE_lib_id.h" #include "BKE_lib_remap.h" #include "BKE_main.h" #include "BKE_material.h" @@ -124,8 +125,8 @@ void ED_editors_init(bContext *C) if (obact == NULL || ob->type != obact->type) { continue; } - /* Object mode is enforced for linked data (or their obdata). */ - if (ID_IS_LINKED(ob) || (ob_data != NULL && ID_IS_LINKED(ob_data))) { + /* Object mode is enforced for non-editable data (or their obdata). */ + if (!BKE_id_is_editable(bmain, &ob->id) || (ob_data != NULL && !BKE_id_is_editable(bmain, ob_data))) { continue; } diff --git a/source/blender/editors/util/ed_util_ops.cc b/source/blender/editors/util/ed_util_ops.cc index 25deacbcdd1..ccc28353518 100644 --- a/source/blender/editors/util/ed_util_ops.cc +++ b/source/blender/editors/util/ed_util_ops.cc @@ -226,7 +226,8 @@ static int lib_id_fake_user_toggle_exec(bContext *C, wmOperator *op) ID *id = (ID *)idptr.data; - if (ID_IS_LINKED(id) || (ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS))) { + if (!BKE_id_is_editable(CTX_data_main(C), 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; } |