diff options
author | Bastien Montagne <bastien@blender.org> | 2022-02-03 16:00:12 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-02-03 16:00:12 +0300 |
commit | e5a110719ff0ea04cd138e4f60c74ff8fc164287 (patch) | |
tree | ba592675f502108d4296ff751eda8ac658a7fa58 /source/blender/editors/object/object_add.c | |
parent | 6c6556c5bd5064872745f7fa6b66d6a2fb744f19 (diff) |
Fix T91254: Some editing operation indirectly delete objects from override collections.
Those cases are fairly hard to track down... Added some more checks,
also at lower levels, more generic levels of object editing, and fixed
core check in liboverride (previously code was assuming that an override
of a collection only could have overrides of objects or linked objects,
but this is not necessarily true).
Diffstat (limited to 'source/blender/editors/object/object_add.c')
-rw-r--r-- | source/blender/editors/object/object_add.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 06e21f91d04..8a493eb0743 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1998,6 +1998,10 @@ void ED_object_base_free_and_unlink(Main *bmain, Scene *scene, Object *ob) ob->id.name + 2); return; } + if (!BKE_lib_override_library_id_is_user_deletable(bmain, &ob->id)) { + /* Do not delete objects used by overrides of collections. */ + return; + } DEG_id_tag_update_ex(bmain, &ob->id, ID_RECALC_BASE_FLAGS); @@ -2038,10 +2042,9 @@ static int object_delete_exec(bContext *C, wmOperator *op) } if (!BKE_lib_override_library_id_is_user_deletable(bmain, &ob->id)) { - /* Can this case ever happen? */ BKE_reportf(op->reports, RPT_WARNING, - "Cannot delete object '%s' as it used by override collections", + "Cannot delete object '%s' as it is used by override collections", ob->id.name + 2); continue; } @@ -3731,6 +3734,7 @@ static bool object_join_poll(bContext *C) static int object_join_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); if (ob->mode & OB_MODE_EDIT) { @@ -3741,6 +3745,14 @@ static int object_join_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data"); return OPERATOR_CANCELLED; } + if (!BKE_lib_override_library_id_is_user_deletable(bmain, &ob->id)) { + BKE_reportf(op->reports, + RPT_WARNING, + "Cannot edit object '%s' as it is used by override collections", + ob->id.name + 2); + return OPERATOR_CANCELLED; + } + if (ob->type == OB_GPENCIL) { bGPdata *gpd = (bGPdata *)ob->data; if ((!gpd) || GPENCIL_ANY_MODE(gpd)) { @@ -3829,6 +3841,7 @@ static bool join_shapes_poll(bContext *C) static int join_shapes_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); if (ob->mode & OB_MODE_EDIT) { @@ -3839,6 +3852,13 @@ static int join_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot edit external library data"); return OPERATOR_CANCELLED; } + if (!BKE_lib_override_library_id_is_user_deletable(bmain, &ob->id)) { + BKE_reportf(op->reports, + RPT_WARNING, + "Cannot edit object '%s' as it is used by override collections", + ob->id.name + 2); + return OPERATOR_CANCELLED; + } if (ob->type == OB_MESH) { return ED_mesh_shapes_join_objects_exec(C, op); |