diff options
author | Bastien Montagne <bastien@blender.org> | 2022-05-11 16:14:44 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-05-11 16:14:44 +0300 |
commit | a3f9862262c0ef192ece6ca8241b67cda9925b32 (patch) | |
tree | 8399f627b312749937f0cc79e2693bced9ede6e9 /source/blender | |
parent | b9d02b9cede338117179897fdcc2d3b1f7499cb3 (diff) |
Fix (unreported) crash in Outliner Overrides Properties view in invalid cases.
We cannot try to get RNA info when the rna path of an override property
is invalid.
Diffstat (limited to 'source/blender')
3 files changed, 30 insertions, 6 deletions
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index d898be4eb2c..36e21cf51a5 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1808,6 +1808,25 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, TreeElementOverridesProperty &override_elem = *tree_element_cast<TreeElementOverridesProperty>( te); + if (!override_elem.is_rna_path_valid) { + uiBut *but = uiDefBut(block, + UI_BTYPE_LABEL, + 0, + override_elem.rna_path.c_str(), + x + pad_x, + te->ys + pad_y, + item_max_width, + item_height, + NULL, + 0.0f, + 0.0f, + 0.0f, + 0.0f, + ""); + UI_but_flag_enable(but, UI_BUT_REDALERT); + continue; + } + PointerRNA *ptr = &override_elem.override_rna_ptr; PropertyRNA *prop = &override_elem.override_rna_prop; const PropertyType prop_type = RNA_property_type(prop); @@ -1935,8 +1954,9 @@ static bool outliner_draw_overrides_warning_buts(uiBlock *block, break; } case TSE_LIBRARY_OVERRIDE: { - const bool is_rna_path_valid = (bool)(POINTER_AS_UINT(te->directdata)); - if (!is_rna_path_valid) { + TreeElementOverridesProperty &te_override_prop = + *tree_element_cast<TreeElementOverridesProperty>(te); + if (!te_override_prop.is_rna_path_valid) { item_has_warnings = true; if (do_draw) { tip = TIP_( diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index 857f5577e59..3a039da86c2 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -84,14 +84,13 @@ TreeElementOverridesProperty::TreeElementOverridesProperty(TreeElement &legacy_t TreeElementOverridesData &override_data) : AbstractTreeElement(legacy_te), override_rna_ptr(override_data.override_rna_ptr), - override_rna_prop(override_data.override_rna_prop) + override_rna_prop(override_data.override_rna_prop), + rna_path(override_data.override_property.rna_path), + is_rna_path_valid(override_data.is_rna_path_valid) { BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE); legacy_te.name = override_data.override_property.rna_path; - /* Abusing this for now, better way to do it is also pending current refactor of the whole tree - * code to use C++. */ - legacy_te.directdata = POINTER_FROM_UINT(override_data.is_rna_path_valid); } } // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh index a2d1409f193..b42e1c37a0f 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh @@ -8,6 +8,8 @@ #include "RNA_types.h" +#include "BLI_string_ref.hh" + #include "tree_element.hh" struct ID; @@ -39,6 +41,9 @@ class TreeElementOverridesProperty final : public AbstractTreeElement { PointerRNA override_rna_ptr; PropertyRNA &override_rna_prop; + StringRefNull rna_path; + bool is_rna_path_valid; + public: TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data); }; |