Fix T61043: Blender crashes on VSE zoom / scroll timeline sometimes
authorJörg Müller <nexyon@gmail.com>
Fri, 1 Feb 2019 14:58:12 +0000 (15:58 +0100)
committerJörg Müller <nexyon@gmail.com>
Fri, 1 Feb 2019 14:58:27 +0000 (15:58 +0100)
source/blender/editors/space_sequencer/sequencer_draw.c

index 3318557..3b91488 100644 (file)
@@ -249,7 +249,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
                endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp) / FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
                samplestep = (endsample - startsample) * stepsize / (x2 - x1);
 
-               length = min_ii(floor((waveform->length - startsample) / samplestep), length);
+               length = min_ii(floor((waveform->length - startsample) / samplestep - (x1_offset - x1) / stepsize), length);
 
                if (length < 2) {
                        return;
@@ -277,7 +277,7 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s
                                                value2 = waveform->data[j * 3 + 1];
                                }
                        }
-                       else {
+                       else if (p + 1 < waveform->length) {
                                /* use simple linear interpolation */
                                float f = sampleoffset - p;
                                value1 = (1.0f - f) * value1 + f * waveform->data[p * 3 + 3];