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
This commit is contained in:
Dalai Felinto 2019-11-19 14:15:41 -03:00
parent 83e8765562
commit 9ca2cbdcea
Notes: blender-bot 2023-05-29 09:17:12 +02:00
Referenced by commit bc66810064, Outliner: Fix crash for tooltips on ID operations
Referenced by issue #71673, Making action single user from Blender File -menu crashes blender
Referenced by issue blender/blender-addons#54558, Make Single User on an action or world in Outliner with the view Blender File crash blender
1 changed files with 25 additions and 8 deletions

View File

@ -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);