diff --git a/app/widget/timelinewidget/view/timelineview.cpp b/app/widget/timelinewidget/view/timelineview.cpp index 12434a91d..f5a2f83e4 100644 --- a/app/widget/timelinewidget/view/timelineview.cpp +++ b/app/widget/timelinewidget/view/timelineview.cpp @@ -527,22 +527,24 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, q QRect thumb_rect; painter->setClipRect(preview_rect); painter->setRenderHint(QPainter::SmoothPixmapTransform); - for (int i=preview_rect.left(); itrack()->sequence(); + int width = s->GetVideoParams().width(); + int height = s->GetVideoParams().height(); + int start; + if (height > 0) { // Prevent divide by zero/invalid params + double scale = double(preview_rect.height())/double(height); + thumb_rect.setWidth(width * scale); + start = (preview_rect.left() - int(qFloor(block_in))) / thumb_rect.width() + qFloor(block_in); + } else { + start = preview_rect.left(); + } + + for (int i=start; iparent()->GetVideoParams().frame_rate_as_time_base()) + media_in; QString thumbnail = thumbs->GetValidCacheFilename(time_here); - if (thumbnail.isEmpty()) { - // Jump ahead to next frame, ensuring that frame width > 0 for optimization - if (thumb_rect.width() == 0 && clip->track() && clip->track()->sequence()) { - Sequence *s = clip->track()->sequence(); - int width = s->GetVideoParams().width(); - int height = s->GetVideoParams().height(); - if (height > 0) { // Prevent divide by zero/invalid params - double scale = double(preview_rect.height())/double(height); - thumb_rect.setWidth(width * scale); - } - } - } else { + if (!thumbnail.isEmpty()) { QImage img; if (img.load(thumbnail, "jpg")) { double scale = double(preview_rect.height())/double(img.height());