From 5596f79821caae3d4c1eb608ce77371904f74b80 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 28 Mar 2022 17:34:36 +0200 Subject: 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}. --- source/blender/editors/screen/screen_ops.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/screen/screen_ops.c') 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; } -- cgit v1.2.3