[Bf-blender-cvs] [b7277aac728] master: Outliner: Fix "Unlink" not working for parented objects

Dalai Felinto noreply at git.blender.org
Wed May 1 00:23:48 CEST 2019


Commit: b7277aac728c262a570a79abbfdc1d2cba80684f
Author: Dalai Felinto
Date:   Tue Apr 30 19:15:11 2019 -0300
Branches: master
https://developer.blender.org/rBb7277aac728c262a570a79abbfdc1d2cba80684f

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.

===================================================================

M	source/blender/editors/space_outliner/outliner_tools.c

===================================================================

diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 68688b64b3e..a620af798d7 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -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;



More information about the Bf-blender-cvs mailing list