mainwindow: pdfPreviewReceived(): Don't capture whole preview object in lambda
This commit is contained in:
джерело
64b87dd595
коміт
09aaf1da04
@ -131,11 +131,13 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview)
|
|||||||
if(preview.hasPreviewImage())
|
if(preview.hasPreviewImage())
|
||||||
{
|
{
|
||||||
ClickLabel *label = new ClickLabel();
|
ClickLabel *label = new ClickLabel();
|
||||||
|
QString docPath = preview.documentPath;
|
||||||
|
auto previewPage = preview.page;
|
||||||
label->setPixmap(QPixmap::fromImage(preview.previewImage));
|
label->setPixmap(QPixmap::fromImage(preview.previewImage));
|
||||||
label->setToolTip(preview.documentPath);
|
label->setToolTip(preview.documentPath);
|
||||||
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
ui->scrollAreaWidgetContents->layout()->addWidget(label);
|
||||||
connect(label, &ClickLabel::leftClick,
|
connect(label, &ClickLabel::leftClick,
|
||||||
[=]()
|
[docPath, previewPage]()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
QString command = settings.value("pdfviewer").toString();
|
QString command = settings.value("pdfviewer").toString();
|
||||||
@ -146,15 +148,15 @@ void MainWindow::pdfPreviewReceived(PdfPreview preview)
|
|||||||
{
|
{
|
||||||
QString cmd = splitted[0];
|
QString cmd = splitted[0];
|
||||||
QStringList args = splitted.mid(1);
|
QStringList args = splitted.mid(1);
|
||||||
args.replaceInStrings("%f", preview.documentPath);
|
args.replaceInStrings("%f", docPath);
|
||||||
args.replaceInStrings("%p", QString::number(preview.page));
|
args.replaceInStrings("%p", QString::number(previewPage));
|
||||||
|
|
||||||
QProcess::startDetached(cmd, args);
|
QProcess::startDetached(cmd, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(preview.documentPath));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(docPath));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Завантаження…
Посилання в новій задачі
Block a user