[Bf-blender-cvs] [851dff6ee95] draw-deferred-compilation-experiment: Fix T97356: Crash when adding adjustment layer strip

Richard Antalik noreply at git.blender.org
Thu Apr 21 11:14:14 CEST 2022


Commit: 851dff6ee95f2df2c27eb0217786c53317857ef4
Author: Richard Antalik
Date:   Thu Apr 21 00:05:57 2022 +0200
Branches: draw-deferred-compilation-experiment
https://developer.blender.org/rB851dff6ee95f2df2c27eb0217786c53317857ef4

Fix T97356: Crash when adding adjustment layer strip

Crash was caused by incorrectly assuming, that rendered strip is meta
when editing code in bulk, but this wasn't true and strip had no
channels initialized, which caused crash on NULL dereference.

Correct approach is to find list of channels where on same level as
rendered strip, similar to how `SEQ_get_seqbase_by_seq` function works
for list of strips.

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

M	source/blender/sequencer/SEQ_channels.h
M	source/blender/sequencer/intern/channels.c
M	source/blender/sequencer/intern/effects.c

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

diff --git a/source/blender/sequencer/SEQ_channels.h b/source/blender/sequencer/SEQ_channels.h
index 1d87875fb26..9436d5dfa32 100644
--- a/source/blender/sequencer/SEQ_channels.h
+++ b/source/blender/sequencer/SEQ_channels.h
@@ -15,6 +15,7 @@ struct Editing;
 struct ListBase;
 struct Scene;
 struct SeqTimelineChannel;
+struct Sequence;
 
 struct ListBase *SEQ_channels_displayed_get(struct Editing *ed);
 void SEQ_channels_displayed_set(struct Editing *ed, struct ListBase *channels);
@@ -28,6 +29,7 @@ char *SEQ_channel_name_get(struct ListBase *channels, const int channel_index);
 bool SEQ_channel_is_locked(const struct SeqTimelineChannel *channel);
 bool SEQ_channel_is_muted(const struct SeqTimelineChannel *channel);
 int SEQ_channel_index_get(const struct SeqTimelineChannel *channel);
+ListBase *SEQ_get_channels_by_seq(struct ListBase *seqbase, const struct Sequence *seq);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/sequencer/intern/channels.c b/source/blender/sequencer/intern/channels.c
index e8e82af03f5..21e3461c7d0 100644
--- a/source/blender/sequencer/intern/channels.c
+++ b/source/blender/sequencer/intern/channels.c
@@ -81,3 +81,19 @@ bool SEQ_channel_is_muted(const SeqTimelineChannel *channel)
 {
   return (channel->flag & SEQ_CHANNEL_MUTE) != 0;
 }
+
+ListBase *SEQ_get_channels_by_seq(ListBase *seqbase, const Sequence *seq)
+{
+  ListBase *lb = NULL;
+
+  LISTBASE_FOREACH (Sequence *, iseq, seqbase) {
+    if (seq == iseq) {
+      return seqbase;
+    }
+    if ((lb = SEQ_get_channels_by_seq(&iseq->seqbase, seq))) {
+      return lb;
+    }
+  }
+
+  return NULL;
+}
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index 0192f4f625c..f4fc79a6572 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -44,6 +44,7 @@
 
 #include "RE_pipeline.h"
 
+#include "SEQ_channels.h"
 #include "SEQ_effects.h"
 #include "SEQ_proxy.h"
 #include "SEQ_relations.h"
@@ -2421,8 +2422,6 @@ static ImBuf *do_multicam(const SeqRenderData *context,
 {
   ImBuf *out;
   Editing *ed;
-  ListBase *seqbasep;
-  ListBase *channels = &seq->channels;
 
   if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) {
     return NULL;
@@ -2432,7 +2431,8 @@ static ImBuf *do_multicam(const SeqRenderData *context,
   if (!ed) {
     return NULL;
   }
-  seqbasep = SEQ_get_seqbase_by_seq(&ed->seqbase, seq);
+  ListBase *seqbasep = SEQ_get_seqbase_by_seq(&ed->seqbase, seq);
+  ListBase *channels = SEQ_get_channels_by_seq(&ed->seqbase, seq);
   if (!seqbasep) {
     return NULL;
   }
@@ -2463,13 +2463,12 @@ static int early_out_adjustment(Sequence *UNUSED(seq), float UNUSED(fac))
 static ImBuf *do_adjustment_impl(const SeqRenderData *context, Sequence *seq, float timeline_frame)
 {
   Editing *ed;
-  ListBase *seqbasep;
-  ListBase *channels = &seq->channels;
   ImBuf *i = NULL;
 
   ed = context->scene->ed;
 
-  seqbasep = SEQ_get_seqbase_by_seq(&ed->seqbase, seq);
+  ListBase *seqbasep = SEQ_get_seqbase_by_seq(&ed->seqbase, seq);
+  ListBase *channels = SEQ_get_channels_by_seq(&ed->seqbase, seq);
 
   /* Clamp timeline_frame to strip range so it behaves as if it had "still frame" offset (last
    * frame is static after end of strip). This is how most strips behave. This way transition



More information about the Bf-blender-cvs mailing list