[Bf-blender-cvs] [9ca2cbdcea6] master: Outliner: Don't show id operations (make single user) when not supported

Dalai Felinto noreply at git.blender.org
Tue Nov 19 18:29:11 CET 2019


Commit: 9ca2cbdcea6a8e46a07348ae35cdecfb0637eb9f
Author: Dalai Felinto
Date:   Tue Nov 19 14:15:41 2019 -0300
Branches: master
https://developer.blender.org/rB9ca2cbdcea6a8e46a07348ae35cdecfb0637eb9f

Outliner: Don't show id operations (make single user) when not supported

For the make single user operation to work we expect a parent of the
datablock to be around. However this is often not the case when not
accessing the data from Scenes or Viewlayer display modes.

For now we simply not show them in the other cases. They can be added
later though, by testing the outliner tree parent compatibility with the
expected parent id.

Fix T71673
Differential Revision: https://developer.blender.org/D6276

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

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 219943d08a6..d6509986249 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -1528,21 +1528,38 @@ static const EnumPropertyItem prop_id_op_types[] = {
     {0, NULL, 0, NULL, NULL},
 };
 
-static const EnumPropertyItem *outliner_id_operation_itemf(bContext *UNUSED(C),
-                                                           PointerRNA *UNUSED(ptr),
-                                                           PropertyRNA *UNUSED(prop),
-                                                           bool *r_free)
+static bool outliner_id_operation_item_poll(bContext *C,
+                                            PointerRNA *UNUSED(ptr),
+                                            PropertyRNA *UNUSED(prop),
+                                            const int enum_value)
 {
-  if (BKE_override_library_is_enabled()) {
-    *r_free = false;
-    return prop_id_op_types;
+  SpaceOutliner *soops = CTX_wm_space_outliner(C);
+
+  switch (enum_value) {
+    case OUTLINER_IDOP_OVERRIDE_LIBRARY:
+      return BKE_override_library_is_enabled();
+    case OUTLINER_IDOP_SINGLE:
+      if (ELEM(soops->outlinevis, SO_SCENES, SO_VIEW_LAYER)) {
+        return true;
+      }
+      /* TODO (dalai): enable in the few cases where this can be supported
+      (i.e., when we have a valid parent for the tselem). */
+      return false;
   }
 
+  return true;
+}
+
+static const EnumPropertyItem *outliner_id_operation_itemf(bContext *C,
+                                                           PointerRNA *ptr,
+                                                           PropertyRNA *prop,
+                                                           bool *r_free)
+{
   EnumPropertyItem *items = NULL;
   int totitem = 0;
 
   for (const EnumPropertyItem *it = prop_id_op_types; it->identifier != NULL; it++) {
-    if (it->value == OUTLINER_IDOP_OVERRIDE_LIBRARY) {
+    if (!outliner_id_operation_item_poll(C, ptr, prop, it->value)) {
       continue;
     }
     RNA_enum_item_add(&items, &totitem, it);



More information about the Bf-blender-cvs mailing list