Outliner: Fix "Unlink" not working for parented objects

How to reproduce it:
* Parent an object to another in the same collection.
* RMB the child object and try to "unlink" it.
This commit is contained in:
Dalai Felinto 2019-04-30 19:15:11 -03:00
parent 910b886747
commit b7277aac72
1 changed files with 10 additions and 1 deletions

View File

@ -283,7 +283,7 @@ static void unlink_collection_cb(bContext *C,
static void unlink_object_cb(bContext *C,
ReportList *UNUSED(reports),
Scene *UNUSED(scene),
TreeElement *UNUSED(te),
TreeElement *te,
TreeStoreElem *tsep,
TreeStoreElem *tselem,
void *UNUSED(user_data))
@ -291,6 +291,15 @@ static void unlink_object_cb(bContext *C,
Main *bmain = CTX_data_main(C);
Object *ob = (Object *)tselem->id;
if (GS(tsep->id->name) == ID_OB) {
/* Parented objects need to find which collection to unlink from. */
TreeElement *te_parent = te->parent;
while (tsep && GS(tsep->id->name) == ID_OB) {
te_parent = te_parent->parent;
tsep = te_parent ? TREESTORE(te_parent) : NULL;
}
}
if (tsep) {
if (GS(tsep->id->name) == ID_GR) {
Collection *parent = (Collection *)tsep->id;