Fix T91873: Crash when opening properties panel

This patch fixes a crash that was recently introduced by rB5cebcb415e76.
The reason were missing poll functions in the UI and operator.

Reviewed By: ISS

Maniphest Tasks: T91873

Differential Revision: https://developer.blender.org/D12736
This commit is contained in:
Falk David 2021-10-04 08:14:06 +02:00
parent 93e92ac126
commit fc6228bd85
Notes: blender-bot 2023-02-14 02:22:13 +01:00
Referenced by issue #92038, VSE - Crash to desktop with a loaded video and open the sidebar in Preview window
Referenced by issue #91873, Video editing crash
2 changed files with 30 additions and 11 deletions

View File

@ -1048,16 +1048,23 @@ class SequencerButtonsPanel_Output:
return cls.has_preview(context)
class SEQUENCER_PT_color_tag_picker(Panel):
bl_label = "Color Tag"
class SequencerColorTagPicker:
bl_space_type = 'SEQUENCE_EDITOR'
bl_region_type = 'UI'
bl_category = "Strip"
bl_options = {'HIDE_HEADER', 'INSTANCED'}
@staticmethod
def has_sequencer(context):
return (context.space_data.view_type in {'SEQUENCER', 'SEQUENCER_PREVIEW'})
@classmethod
def poll(cls, context):
return context.active_sequence_strip is not None
return cls.has_sequencer(context) and context.active_sequence_strip is not None
class SEQUENCER_PT_color_tag_picker(SequencerColorTagPicker, Panel):
bl_label = "Color Tag"
bl_category = "Strip"
bl_options = {'HIDE_HEADER', 'INSTANCED'}
def draw(self, context):
layout = self.layout
@ -1069,13 +1076,9 @@ class SEQUENCER_PT_color_tag_picker(Panel):
row.operator("sequencer.strip_color_tag_set", icon=icon).color = 'COLOR_%02d' % i
class SEQUENCER_MT_color_tag_picker(Menu):
class SEQUENCER_MT_color_tag_picker(SequencerColorTagPicker, Menu):
bl_label = "Set Color Tag"
@classmethod
def poll(cls, context):
return context.active_sequence_strip is not None
def draw(self, context):
layout = self.layout

View File

@ -3339,6 +3339,22 @@ static int sequencer_strip_color_tag_set_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
static bool sequencer_strip_color_tag_set_poll(bContext *C)
{
Scene *scene = CTX_data_scene(C);
if (scene == NULL) {
return false;
}
Editing *ed = SEQ_editing_get(scene);
if (ed == NULL) {
return false;
}
Sequence *act_seq = ed->act_seq;
return act_seq != NULL;
}
void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot)
{
/* Identifiers. */
@ -3348,7 +3364,7 @@ void SEQUENCER_OT_strip_color_tag_set(struct wmOperatorType *ot)
/* Api callbacks. */
ot->exec = sequencer_strip_color_tag_set_exec;
ot->poll = sequencer_edit_poll;
ot->poll = sequencer_strip_color_tag_set_poll;
/* Flags. */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;