diff options
author | Julian Eisel <julian@blender.org> | 2022-01-26 21:11:34 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-01-26 21:15:57 +0300 |
commit | 7b615ca186cab53736fe656d894814c6f92de0e3 (patch) | |
tree | 3c3285206c9ce039cd530f27dccfe2e099163c47 /source/blender/editors/space_outliner/tree | |
parent | 9dc0379dc0023fe45f185dc594dbd4a2fd9fedd3 (diff) |
Cleanup: Remove RNA data from TreeElement, get via type specific class
The `TreeElement.rnaptr` was only needed for RNA tree-elements. Now it
can be gotten through the new type specific classes, e.g.
`TreeElementRNAProperty.getPointerRNA()`.
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_rna.cc | 33 | ||||
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_rna.hh | 1 |
2 files changed, 15 insertions, 19 deletions
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 d33cd7005d7..7a9f1b6f0fa 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc @@ -54,8 +54,6 @@ TreeElementRNACommon::TreeElementRNACommon(TreeElement &legacy_te, PointerRNA &r legacy_te_.name = IFACE_("(empty)"); return; } - - legacy_te_.rnaptr = rna_ptr; } bool TreeElementRNACommon::isExpandValid() const @@ -73,6 +71,11 @@ bool TreeElementRNACommon::expandPoll(const SpaceOutliner &) const return isRNAValid(); } +const PointerRNA &TreeElementRNACommon::getPointerRNA() const +{ + return rna_ptr_; +} + PropertyRNA *TreeElementRNACommon::getPropertyRNA() const { return nullptr; @@ -102,15 +105,15 @@ TreeElementRNAStruct::TreeElementRNAStruct(TreeElement &legacy_te, PointerRNA &r void TreeElementRNAStruct::expand(SpaceOutliner &space_outliner) const { TreeStoreElem &tselem = *TREESTORE(&legacy_te_); - PointerRNA *ptr = &legacy_te_.rnaptr; + PointerRNA ptr = rna_ptr_; /* If searching don't expand RNA entries */ if (SEARCHING_OUTLINER(&space_outliner) && BLI_strcasecmp("RNA", legacy_te_.name) == 0) { tselem.flag &= ~TSE_CHILDSEARCH; } - PropertyRNA *iterprop = RNA_struct_iterator_property(ptr->type); - int tot = RNA_property_collection_length(ptr, iterprop); + PropertyRNA *iterprop = RNA_struct_iterator_property(ptr.type); + int tot = RNA_property_collection_length(&ptr, iterprop); CLAMP_MAX(tot, max_index); TreeElementRNAProperty *parent_prop_te = legacy_te_.parent ? @@ -127,14 +130,10 @@ void TreeElementRNAStruct::expand(SpaceOutliner &space_outliner) const if (TSELEM_OPEN(&tselem, &space_outliner)) { for (int index = 0; index < tot; index++) { PointerRNA propptr; - RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); + RNA_property_collection_lookup_int(&ptr, iterprop, index, &propptr); if (!(RNA_property_flag(reinterpret_cast<PropertyRNA *>(propptr.data)) & PROP_HIDDEN)) { - outliner_add_element(&space_outliner, - &legacy_te_.subtree, - (void *)ptr, - &legacy_te_, - TSE_RNA_PROPERTY, - index); + outliner_add_element( + &space_outliner, &legacy_te_.subtree, &ptr, &legacy_te_, TSE_RNA_PROPERTY, index); } } } @@ -184,7 +183,7 @@ void TreeElementRNAProperty::expand(SpaceOutliner &space_outliner) const if (pptr.data) { if (TSELEM_OPEN(&tselem, &space_outliner)) { outliner_add_element( - &space_outliner, &legacy_te_.subtree, (void *)&pptr, &legacy_te_, TSE_RNA_STRUCT, -1); + &space_outliner, &legacy_te_.subtree, &pptr, &legacy_te_, TSE_RNA_STRUCT, -1); } else { legacy_te_.flag |= TE_LAZY_CLOSED; @@ -199,12 +198,8 @@ void TreeElementRNAProperty::expand(SpaceOutliner &space_outliner) const for (int index = 0; index < tot; index++) { PointerRNA pptr; RNA_property_collection_lookup_int(&rna_ptr, rna_prop_, index, &pptr); - outliner_add_element(&space_outliner, - &legacy_te_.subtree, - (void *)&pptr, - &legacy_te_, - TSE_RNA_STRUCT, - index); + outliner_add_element( + &space_outliner, &legacy_te_.subtree, &pptr, &legacy_te_, TSE_RNA_STRUCT, index); } } else if (tot) { diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.hh b/source/blender/editors/space_outliner/tree/tree_element_rna.hh index 8f53a8b7f31..1f107ddbf88 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.hh @@ -43,6 +43,7 @@ class TreeElementRNACommon : public AbstractTreeElement { bool isExpandValid() const override; bool expandPoll(const SpaceOutliner &) const override; + const PointerRNA &getPointerRNA() const; /** * If this element represents a property or is part of a property (array element), this returns * the property. Otherwise nullptr. |