Outliner: Fix assert on unreachable code in LibOverride view.

Collections also suport replacing their values in some case (e.g. when
it's a collection of ID pointers).
This commit is contained in:
Bastien Montagne
2023-07-04 15:02:25 +02:00
parent fac69131ab
commit 715bc6b200
2 changed files with 37 additions and 20 deletions

View File

@@ -1853,21 +1853,23 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block,
tree_element_cast<TreeElementOverridesPropertyOperation>(te))
{
StringRefNull op_label = override_op_elem->getOverrideOperationLabel();
uiDefBut(block,
UI_BTYPE_LABEL,
0,
op_label.c_str(),
x + pad_x,
te->ys + pad_y,
item_max_width,
item_height,
nullptr,
0,
0,
0,
0,
"");
continue;
if (!op_label.is_empty()) {
uiDefBut(block,
UI_BTYPE_LABEL,
0,
op_label.c_str(),
x + pad_x,
te->ys + pad_y,
item_max_width,
item_height,
nullptr,
0,
0,
0,
0,
"");
continue;
}
}
PointerRNA *ptr = &override_elem->override_rna_ptr;

View File

@@ -230,12 +230,27 @@ TreeElementOverridesPropertyOperation::TreeElementOverridesPropertyOperation(
StringRefNull TreeElementOverridesPropertyOperation::getOverrideOperationLabel() const
{
if (ELEM(operation_->operation, LIBOVERRIDE_OP_INSERT_AFTER, LIBOVERRIDE_OP_INSERT_BEFORE)) {
return TIP_("Added through override");
switch (operation_->operation) {
case LIBOVERRIDE_OP_INSERT_AFTER:
case LIBOVERRIDE_OP_INSERT_BEFORE:
return TIP_("Added through override");
case LIBOVERRIDE_OP_REPLACE:
/* Returning nothing so that drawing code shows actual RNA button instead. */
return {};
/* Following cases are not expected in regular situation, but could be found in experimental
* files. */
case LIBOVERRIDE_OP_NOOP:
return TIP_("Protected from override");
case LIBOVERRIDE_OP_ADD:
return TIP_("Additive override");
case LIBOVERRIDE_OP_SUBTRACT:
return TIP_("Substractive override");
case LIBOVERRIDE_OP_MULTIPLY:
return TIP_("Multiplicative override");
default:
BLI_assert_unreachable();
return {};
}
BLI_assert_unreachable();
return {};
}
std::optional<BIFIconID> TreeElementOverridesPropertyOperation::getIcon() const