[Bf-blender-cvs] [18ccf328ac5] master: Outliner: Fix (unreported) object select in multiple collections

Nathan Craddock noreply at git.blender.org
Thu Jun 18 04:36:36 CEST 2020


Commit: 18ccf328ac5611221e073aebaddde1b0b2169984
Author: Nathan Craddock
Date:   Wed Jun 17 20:15:21 2020 -0600
Branches: master
https://developer.blender.org/rB18ccf328ac5611221e073aebaddde1b0b2169984

Outliner: Fix (unreported) object select in multiple collections

Previous commits to fix parent selection introduced incorrect behavior
when selecting objects linked to multiple collections. The clicked
object would be selected, but also the first listed object in the tree
would be selected.

Instead of always searching for a parent object to select, only search
back when the selected element is not an ID_OB. This prevents multiple
selection of objects linked to multiple collections.

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

M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_utils.c

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

diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index f2b64bc2a4b..3a928485711 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -495,6 +495,7 @@ TreeElement *outliner_find_parent_element(ListBase *lb,
 TreeElement *outliner_find_id(struct SpaceOutliner *soops, ListBase *lb, const struct ID *id);
 TreeElement *outliner_find_posechannel(ListBase *lb, const struct bPoseChannel *pchan);
 TreeElement *outliner_find_editbone(ListBase *lb, const struct EditBone *ebone);
+TreeElement *outliner_search_back_te(TreeElement *te, short idcode);
 struct ID *outliner_search_back(TreeElement *te, short idcode);
 bool outliner_tree_traverse(const SpaceOutliner *soops,
                             ListBase *tree,
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index fa8422573ab..40fb5c7be3a 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -302,28 +302,32 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p
 static eOLDrawState tree_element_set_active_object(bContext *C,
                                                    Scene *scene,
                                                    ViewLayer *view_layer,
-                                                   SpaceOutliner *soops,
+                                                   SpaceOutliner *UNUSED(soops),
                                                    TreeElement *te,
                                                    const eOLSetState set,
                                                    bool recursive)
 {
   TreeStoreElem *tselem = TREESTORE(te);
   TreeStoreElem *parent_tselem = NULL;
+  TreeElement *parent_te = NULL;
   Scene *sce;
   Base *base;
   Object *ob = NULL;
-  TreeElement *te_ob = NULL;
 
   /* if id is not object, we search back */
-  if (te->idcode == ID_OB) {
+  if (tselem->type == 0 && te->idcode == ID_OB) {
     ob = (Object *)tselem->id;
   }
   else {
-    ob = (Object *)outliner_search_back(te, ID_OB);
-
-    /* Don't return when activating children of the previous active object. */
-    if (ob == OBACT(view_layer) && set == OL_SETSEL_NONE) {
-      return OL_DRAWSEL_NONE;
+    parent_te = outliner_search_back_te(te, ID_OB);
+    if (parent_te) {
+      parent_tselem = TREESTORE(parent_te);
+      ob = (Object *)parent_tselem->id;
+
+      /* Don't return when activating children of the previous active object. */
+      if (ob == OBACT(view_layer) && set == OL_SETSEL_NONE) {
+        return OL_DRAWSEL_NONE;
+      }
     }
   }
   if (ob == NULL) {
@@ -356,11 +360,6 @@ static eOLDrawState tree_element_set_active_object(bContext *C,
     }
   }
 
-  te_ob = outliner_find_id(soops, &soops->tree, (ID *)ob);
-  if (te_ob != NULL && te_ob != te) {
-    parent_tselem = TREESTORE(te_ob);
-  }
-
   if (base) {
     if (set == OL_SETSEL_EXTEND) {
       /* swap select */
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index a058c30cef2..5f19d8b8757 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -256,7 +256,7 @@ TreeElement *outliner_find_editbone(ListBase *lb, const EditBone *ebone)
   return NULL;
 }
 
-ID *outliner_search_back(TreeElement *te, short idcode)
+TreeElement *outliner_search_back_te(TreeElement *te, short idcode)
 {
   TreeStoreElem *tselem;
   te = te->parent;
@@ -264,13 +264,26 @@ ID *outliner_search_back(TreeElement *te, short idcode)
   while (te) {
     tselem = TREESTORE(te);
     if (tselem->type == 0 && te->idcode == idcode) {
-      return tselem->id;
+      return te;
     }
     te = te->parent;
   }
   return NULL;
 }
 
+ID *outliner_search_back(TreeElement *te, short idcode)
+{
+  TreeElement *search_te;
+  TreeStoreElem *tselem;
+
+  search_te = outliner_search_back_te(te, idcode);
+  if (search_te) {
+    tselem = TREESTORE(search_te);
+    return tselem->id;
+  }
+  return NULL;
+}
+
 /**
  * Iterate over all tree elements (pre-order traversal), executing \a func callback for
  * each tree element matching the optional filters.



More information about the Bf-blender-cvs mailing list