Refactor: Remove hack to store sequence type in Outliner tree element

`TreeElement.idcode` would be reused to store the sequence type. This is
risky if the field is assumed to actually contain a valid ID-code,
without further checks.
This was only accessed in one place, which I've refactored to a clean,
type-safe solution now.
This commit is contained in:
Julian Eisel
2023-08-10 16:48:58 +02:00
parent b56fc47eed
commit c0065979a1
4 changed files with 15 additions and 13 deletions
@@ -72,6 +72,7 @@
#include "tree/tree_element_id.hh"
#include "tree/tree_element_overrides.hh"
#include "tree/tree_element_rna.hh"
#include "tree/tree_element_seq.hh"
#include "tree/tree_iterator.hh"
namespace blender::ed::outliner {
@@ -2762,8 +2763,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
case TSE_POSEGRP:
data.icon = ICON_GROUP_BONE;
break;
case TSE_SEQUENCE:
switch (te->idcode) {
case TSE_SEQUENCE: {
const TreeElementSequence *te_seq = tree_element_cast<TreeElementSequence>(te);
switch (te_seq->getSequenceType()) {
case SEQ_TYPE_SCENE:
data.icon = ICON_SCENE_DATA;
break;
@@ -2816,6 +2818,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
break;
}
break;
}
case TSE_SEQ_STRIP:
data.icon = ICON_LIBRARY_DATA_DIRECT;
break;
@@ -22,13 +22,6 @@ TreeElementSequence::TreeElementSequence(TreeElement &legacy_te, Sequence &seque
: AbstractTreeElement(legacy_te), sequence_(sequence)
{
BLI_assert(legacy_te.store_elem->type == TSE_SEQUENCE);
/*
* The idcode is a little hack, but the outliner
* only check te->idcode if te->type is equal to zero,
* so this is "safe".
*/
legacy_te.idcode = sequence_.type;
legacy_te.name = sequence_.name + 2;
}
@@ -62,6 +55,11 @@ Sequence &TreeElementSequence::getSequence() const
return sequence_;
}
SequenceType TreeElementSequence::getSequenceType() const
{
return SequenceType(sequence_.type);
}
/* -------------------------------------------------------------------- */
/* Strip */
@@ -86,8 +84,6 @@ TreeElementSequenceStripDuplicate::TreeElementSequenceStripDuplicate(TreeElement
: AbstractTreeElement(legacy_te), sequence_(sequence)
{
BLI_assert(legacy_te.store_elem->type == TSE_SEQUENCE_DUP);
legacy_te_.idcode = sequence.type;
legacy_te_.name = sequence.strip->stripdata->filename;
}
@@ -8,6 +8,8 @@
#pragma once
#include "DNA_sequence_types.h"
#include "tree_element.hh"
struct Sequence;
@@ -25,6 +27,7 @@ class TreeElementSequence : public AbstractTreeElement {
void expand(SpaceOutliner &) const override;
Sequence &getSequence() const;
SequenceType getSequenceType() const;
};
/* -------------------------------------------------------------------- */
+2 -2
View File
@@ -679,7 +679,7 @@ enum {
*
* \warning #SEQ_TYPE_EFFECT BIT is used to determine if this is an effect strip!
*/
enum {
typedef enum SequenceType {
SEQ_TYPE_IMAGE = 0,
SEQ_TYPE_META = 1,
SEQ_TYPE_SCENE = 2,
@@ -731,7 +731,7 @@ enum {
SEQ_TYPE_EXCLUSION = 60,
SEQ_TYPE_MAX = 60,
};
} SequenceType;
enum {
SEQ_MOVIECLIP_RENDER_UNDISTORTED = 1 << 0,