Fix: VSE: Various crashes when sequencer scene is not initialized

Most of these crashes happen because it is assumed that the scene will
always be present even if we have an uninitialized `Editing`, which is
no longer the case with #140271.

- Fix crash when clicking and dragging in the scrub area by checking for
  valid `sequencer_scene` in `change_frame_poll`
- Fix crashes when selecting menu items by disabling them in the UI
  until a `sequencer_scene` is present
- Fix crashes running operators from the F3 menu by changing to more
  restrictive polls that check for `sequencer_scene`
- For good measure, check before dereferencing in
  `channels_displayed_get`, `active_seqbase_get`, and `editing_get`

Pull Request: https://projects.blender.org/blender/blender/pulls/145145
This commit is contained in:
John Kiril Swenson
2025-08-26 11:53:49 +02:00
committed by Falk David
parent 30d546cdca
commit 7bd19f7efb
9 changed files with 58 additions and 46 deletions

View File

@@ -111,6 +111,9 @@ static bool change_frame_poll(bContext *C)
return true;
}
if (area->spacetype == SPACE_SEQ) {
if (!CTX_data_sequencer_scene(C)) {
return false;
}
/* Check the region type so tools (which are shared between preview/strip view)
* don't conflict with actions which can have the same key bound (2D cursor for example). */
const ARegion *region = CTX_wm_region(C);

View File

@@ -930,7 +930,7 @@ void ANIM_OT_keyframe_clear_vse(wmOperatorType *ot)
ot->invoke = clear_anim_vse_invoke;
ot->exec = clear_anim_vse_exec;
ot->poll = ED_operator_areaactive;
ot->poll = ED_operator_sequencer_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1120,7 +1120,7 @@ void ANIM_OT_keyframe_delete_vse(wmOperatorType *ot)
ot->invoke = delete_key_vse_invoke;
ot->exec = delete_key_vse_exec;
ot->poll = ED_operator_areaactive;
ot->poll = ED_operator_sequencer_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;

View File

@@ -39,6 +39,7 @@
#include "RNA_prototypes.hh"
#include "SEQ_iterator.hh"
#include "SEQ_sequencer.hh"
#include "UI_interface.hh"
#include "UI_interface_layout.hh"
@@ -776,7 +777,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot)
static bool sound_poll(bContext *C)
{
Editing *ed = CTX_data_sequencer_scene(C)->ed;
Editing *ed = blender::seq::editing_get(CTX_data_sequencer_scene(C));
if (!ed || !ed->act_strip || ed->act_strip->type != STRIP_TYPE_SOUND_RAM) {
return false;
@@ -789,7 +790,7 @@ static bool sound_poll(bContext *C)
static wmOperatorStatus sound_pack_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Editing *ed = CTX_data_sequencer_scene(C)->ed;
Editing *ed = blender::seq::editing_get(CTX_data_sequencer_scene(C));
bSound *sound;
if (!ed || !ed->act_strip || ed->act_strip->type != STRIP_TYPE_SOUND_RAM) {
@@ -862,7 +863,7 @@ static wmOperatorStatus sound_unpack_exec(bContext *C, wmOperator *op)
static wmOperatorStatus sound_unpack_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
{
Editing *ed = CTX_data_sequencer_scene(C)->ed;
Editing *ed = blender::seq::editing_get(CTX_data_sequencer_scene(C));
bSound *sound;
if (RNA_struct_property_is_set(op->ptr, "id")) {

View File

@@ -141,6 +141,7 @@ void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot)
/* API callbacks. */
ot->invoke = sequencer_rebuild_proxy_invoke;
ot->exec = sequencer_rebuild_proxy_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER;
@@ -236,6 +237,7 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot)
/* API callbacks. */
ot->invoke = sequencer_enable_proxies_invoke;
ot->exec = sequencer_enable_proxies_exec;
ot->poll = sequencer_edit_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER;

View File

@@ -280,7 +280,8 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot)
static wmOperatorStatus sequencer_view_zoom_ratio_exec(bContext *C, wmOperator *op)
{
const RenderData *rd = &CTX_data_sequencer_scene(C)->r;
const Scene *scene = CTX_data_sequencer_scene(C);
const RenderData *rd = &scene->r;
View2D *v2d = UI_view2d_fromcontext(C);
float ratio = RNA_float_get(op->ptr, "ratio");

View File

@@ -27,7 +27,7 @@ namespace blender::seq {
ListBase *channels_displayed_get(const Editing *ed)
{
return ed->current_channels();
return ed ? ed->current_channels() : nullptr;
}
void channels_displayed_set(Editing *ed, ListBase *channels)

View File

@@ -274,7 +274,7 @@ void seq_free_strip_recurse(Scene *scene, Strip *strip, const bool do_id_user)
Editing *editing_get(const Scene *scene)
{
return scene->ed;
return scene ? scene->ed : nullptr;
}
Editing *editing_ensure(Scene *scene)
@@ -422,11 +422,7 @@ int tool_settings_pivot_point_get(Scene *scene)
ListBase *active_seqbase_get(const Editing *ed)
{
if (ed == nullptr) {
return nullptr;
}
return ed->current_strips();
return ed ? ed->current_strips() : nullptr;
}
void active_seqbase_set(Editing *ed, ListBase *seqbase)