diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/lib_override.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_add.c | 24 |
2 files changed, 22 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c index c3b2eae83d4..314351e4ad7 100644 --- a/source/blender/blenkernel/intern/lib_override.c +++ b/source/blender/blenkernel/intern/lib_override.c @@ -2906,10 +2906,6 @@ void BKE_lib_override_library_main_update(Main *bmain) bool BKE_lib_override_library_id_is_user_deletable(struct Main *bmain, struct ID *id) { - if (!(ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY(id))) { - return true; - } - /* The only strong known case currently are objects used by override collections. */ /* TODO: There are most likely other cases... This may need to be addressed in a better way at * some point. */ 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); |