Fix T101499: Do not allow unlinking objects from linked collections.
This commit is contained in:
parent
8f8eac78cf
commit
197f3d75d1
Notes:
blender-bot
2023-02-13 22:38:46 +01:00
Referenced by issue #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #101499, Unlinked objects reappear when reloading the file
|
@ -380,7 +380,7 @@ static void unlink_collection_fn(bContext *C,
|
|||
}
|
||||
|
||||
static void unlink_object_fn(bContext *C,
|
||||
ReportList *UNUSED(reports),
|
||||
ReportList *reports,
|
||||
Scene *UNUSED(scene),
|
||||
TreeElement *te,
|
||||
TreeStoreElem *tsep,
|
||||
|
@ -395,12 +395,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);
|
||||
|
|
Loading…
Reference in New Issue