From d6df8d583b38e551298f090e8ee6e3a6ed77a962 Mon Sep 17 00:00:00 2001 From: Albert S Date: Fri, 5 Mar 2021 21:24:49 +0100 Subject: [PATCH] mainwindow: pdfPreviewReceived(): Don't capture whole preview object in lambda --- gui/mainwindow.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 868c070..4db3d8f 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -129,10 +129,12 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview) if(preview.hasPreviewImage()) { ClickLabel *label = new ClickLabel(); + QString docPath = preview.documentPath; + auto previewPage = preview.page; label->setPixmap(QPixmap::fromImage(preview.previewImage)); label->setToolTip(preview.documentPath); ui->scrollAreaWidgetContents->layout()->addWidget(label); - connect(label, &ClickLabel::leftClick, [=]() { + connect(label, &ClickLabel::leftClick, [docPath, previewPage]() { QSettings settings; QString command = settings.value("pdfviewer").toString(); if(command != "" && command.contains("%p") && command.contains("%f")) @@ -142,15 +144,15 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview) { QString cmd = splitted[0]; QStringList args = splitted.mid(1); - args.replaceInStrings("%f", preview.documentPath); - args.replaceInStrings("%p", QString::number(preview.page)); + args.replaceInStrings("%f", docPath); + args.replaceInStrings("%p", QString::number(previewPage)); QProcess::startDetached(cmd, args); } } else { - QDesktopServices::openUrl(QUrl::fromLocalFile(preview.documentPath)); + QDesktopServices::openUrl(QUrl::fromLocalFile(docPath)); } }); }