From 0d03a92e20ed6c9c83ca907ad50cffe4198606b9 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 17 Jul 2018 02:21:38 +0100 Subject: [PATCH] fixed a fatal timeline bug --- mainwindow.ui | 3 +++ ui/timelinewidget.cpp | 22 +++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index dc4123a59..6be17315d 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -478,6 +478,9 @@ Slip Tool + + Y + diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index a9b667181..9e1bf55cc 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #define MAX_TEXT_WIDTH 20 @@ -622,8 +623,8 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { validator = g.old_in + frame_diff; if (validator < 0) frame_diff -= validator; + // prevent clip_in from going below 0 if (!c->media_stream->infinite_length) { - // prevent clip_in from going below 0 validator = g.old_clip_in + frame_diff; if (validator < 0) frame_diff -= validator; } @@ -632,9 +633,9 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { validator = g.ghost_length + frame_diff; if (validator < 1) frame_diff += (1 - validator); + // prevent clip length exceeding media length if (!c->media_stream->infinite_length) { - // prevent clip length exceeding media length - validator = g.ghost_length + frame_diff; + validator = g.old_clip_in + g.ghost_length + frame_diff; if (validator > g.media_length) frame_diff -= validator - g.media_length; } } @@ -687,7 +688,9 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) { for (int i=0;ighosts.size();i++) { Ghost& g = panel_timeline->ghosts[i]; - if (g.trimming) { + if (panel_timeline->tool == TIMELINE_TOOL_SLIP) { + g.clip_in = g.old_clip_in - frame_diff; + } else if (g.trimming) { if (g.trim_in) { g.in = g.old_in + frame_diff; g.clip_in = g.old_clip_in + frame_diff; @@ -1242,9 +1245,14 @@ void TimelineWidget::redraw_clips() { int mid = clip_rect.top()+channel_height*j+(channel_height/2); int offset = waveform_index+(j*2); - qint8 min = (double)clip->media_stream->audio_preview.at(offset) / 128.0 * (channel_height/2); - qint8 max = (double)clip->media_stream->audio_preview.at(offset+1) / 128.0 * (channel_height/2); - clip_painter.drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max); + if (offset >= 0 && offset < clip->media_stream->audio_preview.size()) { + qint8 min = (double)clip->media_stream->audio_preview.at(offset) / 128.0 * (channel_height/2); + qint8 max = (double)clip->media_stream->audio_preview.at(offset+1) / 128.0 * (channel_height/2); + clip_painter.drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max); + } else { + QMessageBox::critical(this, "AAAAAAAAAAAAA", "Here's that terrible, no-good bug again!!! I've stepped around it but plz report the following to Matt:\n\n" + QString::number(offset) + " vs " + QString::number(clip->media_stream->audio_preview.size()), QMessageBox::Ok); + break; + } } } }