diff options
Diffstat (limited to 'source/blender/editors/space_outliner')
3 files changed, 38 insertions, 10 deletions
diff --git a/source/blender/editors/space_outliner/outliner_collections.cc b/source/blender/editors/space_outliner/outliner_collections.cc index 716d5b67fe3..a4ff44512ef 100644 --- a/source/blender/editors/space_outliner/outliner_collections.cc +++ b/source/blender/editors/space_outliner/outliner_collections.cc @@ -301,7 +301,7 @@ static TreeTraversalAction collection_find_data_to_edit(TreeElement *te, void *c if (ID_IS_OVERRIDE_LIBRARY_REAL(collection)) { if (ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(collection)) { - if (!data->is_liboverride_hierarchy_root_allowed) { + if (!(data->is_liboverride_hierarchy_root_allowed || data->is_liboverride_allowed)) { return TRAVERSE_SKIP_CHILDS; } } diff --git a/source/blender/editors/space_outliner/outliner_edit.cc b/source/blender/editors/space_outliner/outliner_edit.cc index a60e082f6a5..ae67e7108bf 100644 --- a/source/blender/editors/space_outliner/outliner_edit.cc +++ b/source/blender/editors/space_outliner/outliner_edit.cc @@ -447,6 +447,17 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto (tselem->type == TSE_LAYER_COLLECTION)); UNUSED_VARS_NDEBUG(te); + if (ID_IS_OVERRIDE_LIBRARY(id)) { + if (!ID_IS_OVERRIDE_LIBRARY_REAL(id) || + (id->override_library->flag & IDOVERRIDE_LIBRARY_FLAG_NO_HIERARCHY) == 0) { + BKE_reportf(reports, + RPT_WARNING, + "Cannot delete library override id '%s', it is part of an override hierarchy", + id->name); + return; + } + } + if (te->idcode == ID_LI && ((Library *)id)->parent != nullptr) { BKE_reportf(reports, RPT_WARNING, "Cannot delete indirectly linked library '%s'", id->name); return; diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 77336dc1867..55196d042ae 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -1670,6 +1670,12 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot) using OutlinerDeleteFn = void (*)(bContext *C, ReportList *reports, Scene *scene, Object *ob); +typedef struct ObjectEditData { + GSet *objects_set; + bool is_liboverride_allowed; + bool is_liboverride_hierarchy_root_allowed; +} ObjectEditData; + static void outliner_do_object_delete(bContext *C, ReportList *reports, Scene *scene, @@ -1686,7 +1692,8 @@ static void outliner_do_object_delete(bContext *C, static TreeTraversalAction outliner_find_objects_to_delete(TreeElement *te, void *customdata) { - GSet *objects_to_delete = (GSet *)customdata; + ObjectEditData *data = reinterpret_cast<ObjectEditData *>(customdata); + GSet *objects_to_delete = data->objects_set; TreeStoreElem *tselem = TREESTORE(te); if (outliner_is_collection_tree_element(te)) { @@ -1701,9 +1708,15 @@ static TreeTraversalAction outliner_find_objects_to_delete(TreeElement *te, void ID *id = tselem->id; if (ID_IS_OVERRIDE_LIBRARY_REAL(id)) { - if (!ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(id)) { - /* Only allow deletion of liboverride objects if they are root overrides. */ - return TRAVERSE_SKIP_CHILDS; + if (ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(id)) { + if (!(data->is_liboverride_hierarchy_root_allowed || data->is_liboverride_allowed)) { + return TRAVERSE_SKIP_CHILDS; + } + } + else { + if (!data->is_liboverride_allowed) { + return TRAVERSE_SKIP_CHILDS; + } } } @@ -1725,27 +1738,31 @@ static int outliner_delete_exec(bContext *C, wmOperator *op) /* Get selected objects skipping duplicates to prevent deleting objects linked to multiple * collections twice */ - GSet *objects_to_delete = BLI_gset_ptr_new(__func__); + ObjectEditData object_delete_data = {}; + object_delete_data.objects_set = BLI_gset_ptr_new(__func__); + object_delete_data.is_liboverride_allowed = false; + object_delete_data.is_liboverride_hierarchy_root_allowed = delete_hierarchy; outliner_tree_traverse(space_outliner, &space_outliner->tree, 0, TSE_SELECTED, outliner_find_objects_to_delete, - objects_to_delete); + &object_delete_data); if (delete_hierarchy) { BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); outliner_do_object_delete( - C, op->reports, scene, objects_to_delete, object_batch_delete_hierarchy_fn); + C, op->reports, scene, object_delete_data.objects_set, object_batch_delete_hierarchy_fn); BKE_id_multi_tagged_delete(bmain); } else { - outliner_do_object_delete(C, op->reports, scene, objects_to_delete, outliner_object_delete_fn); + outliner_do_object_delete( + C, op->reports, scene, object_delete_data.objects_set, outliner_object_delete_fn); } - BLI_gset_free(objects_to_delete, nullptr); + BLI_gset_free(object_delete_data.objects_set, nullptr); outliner_collection_delete(C, bmain, scene, op->reports, delete_hierarchy); |