[Bf-blender-cvs] [91a488ad186] temp-pbvh-split: Fix (unreported) crash in Outliner Overrides Properties view in invalid cases.

Bastien Montagne noreply at git.blender.org
Fri Jun 3 01:16:31 CEST 2022


Commit: 91a488ad18680de2b9e17cfcd4b738e1b691f9dd
Author: Bastien Montagne
Date:   Wed May 11 15:14:44 2022 +0200
Branches: temp-pbvh-split
https://developer.blender.org/rB91a488ad18680de2b9e17cfcd4b738e1b691f9dd

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.

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

M	source/blender/editors/space_outliner/outliner_draw.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.hh

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

diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index ff99416c213..57b0e2022ff 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -1809,6 +1809,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);
@@ -1936,8 +1955,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);
 };



More information about the Bf-blender-cvs mailing list