Fix #145890: Crash using playhead snapping in VSE in new scene

Code was not guarding against missing `Editing` (like we usually do for
these situations).

This also corrects usage of `CTX_data_scene` (use `CTX_data_sequencer_scene`
where needed instead) which should be needed since 1122a05cb6

Pull Request: https://projects.blender.org/blender/blender/pulls/145908
This commit is contained in:
Philipp Oeser
2025-09-10 09:22:04 +02:00
committed by Philipp Oeser
parent ccdbcaa652
commit 29d18c45e4

View File

@@ -156,7 +156,10 @@ static void ensure_change_frame_keylist(bContext *C, FrameChangeModalData &op_da
/* Special case for the sequencer since it has retiming keys, but those have no bAnimListElem
* representation. Need to manually add entries to keylist. */
op_data.keylist = ED_keylist_create();
Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_sequencer_scene(C);
if (!scene) {
return;
}
ListBase *seqbase = blender::seq::active_seqbase_get(blender::seq::editing_get(scene));
LISTBASE_FOREACH (Strip *, strip, seqbase) {
@@ -355,13 +358,22 @@ static blender::Vector<SnapTarget> seq_get_snap_targets(bContext *C,
FrameChangeModalData &op_data,
const float timeline_frame)
{
Scene *scene = CTX_data_scene(C);
Scene *scene = CTX_data_sequencer_scene(C);
if (!scene) {
return {};
}
ToolSettings *tool_settings = scene->toolsettings;
Editing *ed = blender::seq::editing_get(scene);
if (ed == nullptr) {
return {};
}
blender::Vector<SnapTarget> targets;
if (tool_settings->snap_playhead_mode & SCE_SNAP_TO_STRIPS) {
ListBase *seqbase = blender::seq::active_seqbase_get(blender::seq::editing_get(scene));
ListBase *seqbase = blender::seq::active_seqbase_get(ed);
append_sequencer_strip_snap_target(
blender::seq::query_all_strips(seqbase), scene, timeline_frame, targets);
}
@@ -476,7 +488,12 @@ static float apply_frame_snap(bContext *C, FrameChangeModalData &op_data, const
ScrArea *area = CTX_wm_area(C);
blender::Vector<SnapTarget> targets;
Scene *scene = CTX_data_scene(C);
const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
if (!scene) {
return frame;
}
switch (area->spacetype) {
case SPACE_SEQ:
targets = seq_get_snap_targets(C, op_data, frame);
@@ -618,7 +635,12 @@ static void change_frame_seq_preview_end(SpaceSeq *sseq)
static bool use_playhead_snapping(bContext *C)
{
Scene *scene = CTX_data_scene(C);
const bool is_sequencer = CTX_wm_space_seq(C) != nullptr;
Scene *scene = is_sequencer ? CTX_data_sequencer_scene(C) : CTX_data_scene(C);
if (!scene) {
return false;
}
ScrArea *area = CTX_wm_area(C);
if (area->spacetype == SPACE_GRAPH) {