Skip to content

Commit 2b07a21

Browse files
metsmamrts
authored andcommitted
Fix coverity errors
WE2-1003 Signed-off-by: Raul Metsma <[email protected]>
1 parent 632830c commit 2b07a21

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/ui/webeiddialog.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,12 @@ void WebEidDialog::onMultipleCertificatesReady(
339339
case CommandType::AUTHENTICATE:
340340
ui->selectAnotherCertificate->disconnect();
341341
ui->selectAnotherCertificate->setVisible(certificateAndPinInfos.size() > 1);
342-
connect(ui->selectAnotherCertificate, &QPushButton::clicked, this,
343-
[this, origin, certificateAndPinInfos] {
344-
// We set pinInput to empty text instead of clear() to also reset undo buffer
345-
ui->pinInput->setText({});
346-
onMultipleCertificatesReady(origin, certificateAndPinInfos);
347-
});
348-
setupOK([this, origin] {
342+
connect(ui->selectAnotherCertificate, &QPushButton::clicked, this, [=] {
343+
// We set pinInput to empty text instead of clear() to also reset undo buffer
344+
ui->pinInput->setText({});
345+
onMultipleCertificatesReady(origin, certificateAndPinInfos);
346+
});
347+
setupOK([=] {
349348
ui->okButton->setDisabled(true);
350349
// Authenticate continues with the selected certificate to onSingleCertificateReady().
351350
if (auto* button =
@@ -381,7 +380,7 @@ void WebEidDialog::onSingleCertificateReady(const QUrl& origin,
381380
switch (currentCommand) {
382381
case CommandType::GET_SIGNING_CERTIFICATE:
383382
setupCertificateAndPinInfo({certAndPin});
384-
setupOK([this, certAndPin] {
383+
setupOK([=] {
385384
ui->okButton->setDisabled(true);
386385
emit accepted(certAndPin);
387386
});
@@ -554,7 +553,7 @@ void WebEidDialog::setTrText(QWidget* label, Text text) const
554553
void WebEidDialog::connectOkToCachePinAndEmitSelectedCertificate(
555554
const CardCertificateAndPinInfo& certAndPin)
556555
{
557-
setupOK([this, certAndPin] {
556+
setupOK([=] {
558557
ui->pinInput->hide();
559558
ui->pinTitleLabel->hide();
560559
ui->pinErrorLabel->hide();
@@ -682,14 +681,15 @@ void WebEidDialog::displayPinBlockedError()
682681
displayFatalError([] { return tr("PIN is locked. Unblock and try again."); });
683682
}
684683

685-
void WebEidDialog::displayFatalError(std::function<QString()> message)
684+
template <typename Text>
685+
void WebEidDialog::displayFatalError(Text message)
686686
{
687687
ui->pinTitleLabel->hide();
688688
ui->pinInput->hide();
689689
ui->pinTimeoutTimer->stop();
690690
ui->pinTimeRemaining->hide();
691691
ui->pinEntryTimeoutProgressBar->hide();
692-
setTrText(ui->pinErrorLabel, message);
692+
setTrText(ui->pinErrorLabel, std::forward<Text>(message));
693693
ui->pinErrorLabel->show();
694694
ui->okButton->hide();
695695
ui->cancelButton->setEnabled(true);

src/ui/webeiddialog.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class WebEidDialog final : public WebEidUI
104104
template <typename Func>
105105
void setupOK(Func func, const char* text = {}, bool enabled = false);
106106
void displayPinBlockedError();
107-
void displayFatalError(std::function<QString()> message);
107+
template <typename Text>
108+
void displayFatalError(Text message);
108109

109110
void showPinInputWarning(bool show);
110111
void resizeHeight();

0 commit comments

Comments
 (0)