From 0458b24a239e6070ad6e045ace3b59f57deaf14a Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 4 Oct 2022 14:58:15 +0200 Subject: Fix T101499: Do not allow unlinking objects from linked collections. --- .../blender/editors/space_outliner/outliner_tools.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 2ece9ecc7f2..16b24b14845 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -381,7 +381,7 @@ static void unlink_collection_fn(bContext *C, } static void unlink_object_fn(bContext *C, - ReportList * /*reports*/, + ReportList *reports, Scene * /*scene*/, TreeElement *te, TreeStoreElem *tsep, @@ -396,12 +396,28 @@ static void unlink_object_fn(bContext *C, /* Parented objects need to find which collection to unlink from. */ TreeElement *te_parent = te->parent; while (tsep && GS(tsep->id->name) == ID_OB) { + if (ID_IS_LINKED(tsep->id)) { + BKE_reportf(reports, + RPT_WARNING, + "Cannot unlink object '%s' parented to another linked object '%s'", + ob->id.name + 2, + tsep->id->name + 2); + return; + } te_parent = te_parent->parent; tsep = te_parent ? TREESTORE(te_parent) : nullptr; } } if (tsep && tsep->id) { + if (ID_IS_LINKED(tsep->id) || ID_IS_OVERRIDE_LIBRARY(tsep->id)) { + BKE_reportf(reports, + RPT_WARNING, + "Cannot unlink object '%s' from linked collection or scene '%s'", + ob->id.name + 2, + tsep->id->name + 2); + return; + } if (GS(tsep->id->name) == ID_GR) { Collection *parent = (Collection *)tsep->id; BKE_collection_object_remove(bmain, parent, ob, true); -- cgit v1.2.3