From 431525703d1023ce1efc1723102a0bf023a76313 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 29 Nov 2018 12:07:28 +1100 Subject: [PATCH] returned to QImage because QPixmaps seemed to cause crashes --- io/media.h | 2 +- io/previewgenerator.cpp | 7 +++---- ui/timelinewidget.cpp | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/io/media.h b/io/media.h index 32db5f11f..c746bc217 100644 --- a/io/media.h +++ b/io/media.h @@ -37,7 +37,7 @@ struct MediaStream { // preview thumbnail/waveform bool preview_done; - QPixmap video_preview; + QImage video_preview; QVector audio_preview; }; diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp index 39deb2d08..c0838ac10 100644 --- a/io/previewgenerator.cpp +++ b/io/previewgenerator.cpp @@ -124,10 +124,9 @@ bool PreviewGenerator::retrieve_preview(const QString& hash) { MediaStream* ms = media->video_tracks.at(i); QString thumb_path = get_thumbnail_path(hash, ms); QFile f(thumb_path); - if (f.exists()) { + if (f.exists() && ms->video_preview.load(thumb_path)) { //dout << "loaded thumb" << ms->file_index << "from" << thumb_path; - ms->video_preview.load(thumb_path); - ms->preview_done = true; + ms->preview_done = true; } else { found = false; break; @@ -270,7 +269,7 @@ void PreviewGenerator::generate_waveform() { linesize[0] = dstW*3; sws_scale(sws_ctx, temp_frame->data, temp_frame->linesize, 0, temp_frame->height, &data, linesize); - s->video_preview.convertFromImage(QImage(data, dstW, dstH, linesize[0], QImage::Format_RGB888)); + s->video_preview = QImage(data, dstW, dstH, linesize[0], QImage::Format_RGB888); // is video interlaced? s->video_auto_interlacing = (temp_frame->interlaced_frame) ? ((temp_frame->top_field_first) ? VIDEO_TOP_FIELD_FIRST : VIDEO_BOTTOM_FIELD_FIRST) : VIDEO_PROGRESSIVE; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 043173b27..86a202991 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -2288,7 +2288,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) { && thumb_y + thumb_height >= 0 && space_for_thumb > MAX_TEXT_WIDTH) { int thumb_clip_width = qMin(thumb_width, space_for_thumb); - p.drawPixmap(QRect(thumb_x, clip_rect.y()+thumb_y, thumb_clip_width, thumb_height), ms->video_preview, QRect(0, 0, thumb_clip_width*((double)ms->video_preview.width()/(double)thumb_width), ms->video_preview.height())); + p.drawImage(QRect(thumb_x, clip_rect.y()+thumb_y, thumb_clip_width, thumb_height), ms->video_preview, QRect(0, 0, thumb_clip_width*((double)ms->video_preview.width()/(double)thumb_width), ms->video_preview.height())); } } } else if (clip_rect.height() > TRACK_MIN_HEIGHT) {