Skip to content

Commit

Permalink
Fix coverity errors
Browse files Browse the repository at this point in the history
WE2-1003

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored and mrts committed Sep 20, 2024
1 parent b8d6e7f commit f63b040
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/ui/webeiddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,12 @@ void WebEidDialog::onMultipleCertificatesReady(
case CommandType::AUTHENTICATE:
ui->selectAnotherCertificate->disconnect();
ui->selectAnotherCertificate->setVisible(certificateAndPinInfos.size() > 1);
connect(ui->selectAnotherCertificate, &QPushButton::clicked, this,
[this, origin, certificateAndPinInfos] {
// We set pinInput to empty text instead of clear() to also reset undo buffer
ui->pinInput->setText({});
onMultipleCertificatesReady(origin, certificateAndPinInfos);
});
setupOK([this, origin] {
connect(ui->selectAnotherCertificate, &QPushButton::clicked, this, [=] {
// We set pinInput to empty text instead of clear() to also reset undo buffer
ui->pinInput->setText({});
onMultipleCertificatesReady(origin, certificateAndPinInfos);
});
setupOK([=] {
ui->okButton->setDisabled(true);
// Authenticate continues with the selected certificate to onSingleCertificateReady().
if (auto* button =
Expand Down Expand Up @@ -381,7 +380,7 @@ void WebEidDialog::onSingleCertificateReady(const QUrl& origin,
switch (currentCommand) {
case CommandType::GET_SIGNING_CERTIFICATE:
setupCertificateAndPinInfo({certAndPin});
setupOK([this, certAndPin] {
setupOK([=] {
ui->okButton->setDisabled(true);
emit accepted(certAndPin);
});
Expand Down Expand Up @@ -554,7 +553,7 @@ void WebEidDialog::setTrText(QWidget* label, Text text) const
void WebEidDialog::connectOkToCachePinAndEmitSelectedCertificate(
const CardCertificateAndPinInfo& certAndPin)
{
setupOK([this, certAndPin] {
setupOK([=] {
ui->pinInput->hide();
ui->pinTitleLabel->hide();
ui->pinErrorLabel->hide();
Expand Down Expand Up @@ -682,14 +681,15 @@ void WebEidDialog::displayPinBlockedError()
displayFatalError([] { return tr("PIN is locked. Unblock and try again."); });
}

void WebEidDialog::displayFatalError(std::function<QString()> message)
template <typename Text>
void WebEidDialog::displayFatalError(Text message)
{
ui->pinTitleLabel->hide();
ui->pinInput->hide();
ui->pinTimeoutTimer->stop();
ui->pinTimeRemaining->hide();
ui->pinEntryTimeoutProgressBar->hide();
setTrText(ui->pinErrorLabel, message);
setTrText(ui->pinErrorLabel, std::forward<Text>(message));
ui->pinErrorLabel->show();
ui->okButton->hide();
ui->cancelButton->setEnabled(true);
Expand Down
3 changes: 2 additions & 1 deletion src/ui/webeiddialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class WebEidDialog final : public WebEidUI
template <typename Func>
void setupOK(Func func, const char* text = {}, bool enabled = false);
void displayPinBlockedError();
void displayFatalError(std::function<QString()> message);
template <typename Text>
void displayFatalError(Text message);

void showPinInputWarning(bool show);
void resizeHeight();
Expand Down

0 comments on commit f63b040

Please sign in to comment.