Refactor: Avoid unsafe cast for Outliner sequence elements
Relying on the `TreeStoreElem.id` void pointer makes assumptions about what code elsewhere sets to it (it's also misleading since it's actually not an ID pointer), in this case we can easily avoid that.
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
#include "WM_api.hh"
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "tree/tree_element_seq.hh"
|
||||
|
||||
#include "outliner_intern.hh"
|
||||
|
||||
void ED_outliner_select_sync_from_object_tag(bContext *C)
|
||||
@@ -288,9 +290,12 @@ static void outliner_select_sync_to_pose_bone(TreeElement *te,
|
||||
}
|
||||
}
|
||||
|
||||
static void outliner_select_sync_to_sequence(Scene *scene, TreeStoreElem *tselem)
|
||||
static void outliner_select_sync_to_sequence(Scene *scene, const TreeElement *te)
|
||||
{
|
||||
Sequence *seq = (Sequence *)tselem->id;
|
||||
const TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
const TreeElementSequence *te_sequence = tree_element_cast<TreeElementSequence>(te);
|
||||
Sequence *seq = &te_sequence->getSequence();
|
||||
|
||||
if (tselem->flag & TSE_ACTIVE) {
|
||||
SEQ_select_active_set(scene, seq);
|
||||
@@ -333,7 +338,7 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
|
||||
}
|
||||
else if (tselem->type == TSE_SEQUENCE) {
|
||||
if (sync_types->sequence) {
|
||||
outliner_select_sync_to_sequence(scene, tselem);
|
||||
outliner_select_sync_to_sequence(scene, te);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -464,9 +469,12 @@ static void outliner_select_sync_from_pose_bone(bPoseChannel *pchan_active,
|
||||
}
|
||||
}
|
||||
|
||||
static void outliner_select_sync_from_sequence(Sequence *sequence_active, TreeStoreElem *tselem)
|
||||
static void outliner_select_sync_from_sequence(Sequence *sequence_active, const TreeElement *te)
|
||||
{
|
||||
Sequence *seq = (Sequence *)tselem->id;
|
||||
TreeStoreElem *tselem = TREESTORE(te);
|
||||
|
||||
const TreeElementSequence *te_sequence = tree_element_cast<TreeElementSequence>(te);
|
||||
const Sequence *seq = &te_sequence->getSequence();
|
||||
|
||||
if (seq == sequence_active) {
|
||||
tselem->flag |= TSE_ACTIVE;
|
||||
@@ -522,7 +530,7 @@ static void outliner_sync_selection_to_outliner(const Scene *scene,
|
||||
}
|
||||
else if (tselem->type == TSE_SEQUENCE) {
|
||||
if (sync_types->sequence) {
|
||||
outliner_select_sync_from_sequence(active_data->sequence, tselem);
|
||||
outliner_select_sync_from_sequence(active_data->sequence, te);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user