returned to QImage because QPixmaps seemed to cause crashes

This commit is contained in:
itsmattkc
2018-11-29 12:07:28 +11:00
parent 3069fb6f7c
commit 431525703d
3 changed files with 5 additions and 6 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ struct MediaStream {
// preview thumbnail/waveform
bool preview_done;
QPixmap video_preview;
QImage video_preview;
QVector<char> audio_preview;
};
+3 -4
View File
@@ -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;
+1 -1
View File
@@ -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) {