[Bf-blender-cvs] [d74c2b5c1f2] master: Outliner: Add missing sanity checks for RNA tree-elements

Julian Eisel noreply at git.blender.org
Wed Jan 26 19:16:07 CET 2022


Commit: d74c2b5c1f235fafa8ba9045e59815406c37993f
Author: Julian Eisel
Date:   Wed Jan 26 12:56:03 2022 +0100
Branches: master
https://developer.blender.org/rBd74c2b5c1f235fafa8ba9045e59815406c37993f

Outliner: Add missing sanity checks for RNA tree-elements

Forgot to add these in 9bce134e56c2. Also tweaked assert to print a
message that was previously communicated via a comment only.

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

M	source/blender/editors/space_outliner/outliner_tree.cc
M	source/blender/editors/space_outliner/tree/tree_element_rna.cc

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

diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc
index be792be95a9..8ad40b503bd 100644
--- a/source/blender/editors/space_outliner/outliner_tree.cc
+++ b/source/blender/editors/space_outliner/outliner_tree.cc
@@ -925,9 +925,11 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
                 TSE_NLA,
                 TSE_NLA_ACTION,
                 TSE_NLA_TRACK,
-                TSE_GP_LAYER)) {
-    /* Should already use new AbstractTreeElement design. */
-    BLI_assert(0);
+                TSE_GP_LAYER,
+                TSE_RNA_STRUCT,
+                TSE_RNA_PROPERTY,
+                TSE_RNA_ARRAY_ELEM)) {
+    BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design");
   }
   else if (type == TSE_SEQUENCE) {
     Sequence *seq = (Sequence *)idv;
diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.cc b/source/blender/editors/space_outliner/tree/tree_element_rna.cc
index 0152f59268d..1aa30e1a99a 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc
@@ -79,6 +79,8 @@ bool TreeElementRNACommon::expandPoll(const SpaceOutliner &) const
 TreeElementRNAStruct::TreeElementRNAStruct(TreeElement &legacy_te, PointerRNA &rna_ptr)
     : TreeElementRNACommon(legacy_te, rna_ptr)
 {
+  BLI_assert(legacy_te.store_elem->type == TSE_RNA_STRUCT);
+
   if (!isRNAValid()) {
     return;
   }
@@ -142,6 +144,8 @@ TreeElementRNAProperty::TreeElementRNAProperty(TreeElement &legacy_te,
                                                const int index)
     : TreeElementRNACommon(legacy_te, rna_ptr)
 {
+  BLI_assert(legacy_te.store_elem->type == TSE_RNA_PROPERTY);
+
   if (!isRNAValid()) {
     return;
   }
@@ -229,6 +233,9 @@ TreeElementRNAArrayElement::TreeElementRNAArrayElement(TreeElement &legacy_te,
                                                        const int index)
     : TreeElementRNACommon(legacy_te, rna_ptr)
 {
+  BLI_assert(legacy_te.store_elem->type == TSE_RNA_ARRAY_ELEM);
+
+  BLI_assert(legacy_te.parent && (legacy_te.parent->store_elem->type == TSE_RNA_PROPERTY));
   PropertyRNA *prop = reinterpret_cast<PropertyRNA *>(legacy_te_.parent->directdata);
   legacy_te_.directdata = prop;
   legacy_te_.index = index;



More information about the Bf-blender-cvs mailing list