[Bf-blender-cvs] [fc6228bd852] master: Fix T91873: Crash when opening properties panel

Falk David noreply at git.blender.org
Mon Oct 4 08:15:35 CEST 2021


Commit: fc6228bd8528629da63cd9b5d012b36e0e5e9fee
Author: Falk David
Date:   Mon Oct 4 08:14:06 2021 +0200
Branches: master
https://developer.blender.org/rBfc6228bd8528629da63cd9b5d012b36e0e5e9fee

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

===================================================================

M	release/scripts/startup/bl_ui/space_sequencer.py
M	source/blender/editors/space_sequencer/sequencer_edit.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py
index 197e3efebda..6430d6bab9b 100644
--- a/release/scripts/startup/bl_ui/space_sequencer.py
+++ b/release/scripts/startup/bl_ui/space_sequencer.py
@@ -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
 
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 9be947b9112..d55356eddec 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -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;



More information about the Bf-blender-cvs mailing list