Skip to content

Commit

Permalink
Fix coverity warning (open-eid#1154)
Browse files Browse the repository at this point in the history
IB-7550

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma authored Feb 7, 2023
1 parent 7425df4 commit 5ea92a9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ jobs:
coverity:
name: Run Coverity tests
if: github.repository == 'open-eid/DigiDoc4-Client' && contains(github.ref, 'coverity_scan')
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
PROJECTNAME: open-eid/DigiDoc4-Client
Expand Down Expand Up @@ -262,7 +262,7 @@ jobs:
codeql:
name: Run CodeQL tests
if: github.repository == 'open-eid/DigiDoc4-Client'
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
permissions:
security-events: write
steps:
Expand Down
28 changes: 13 additions & 15 deletions client/dialogs/KeyDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
#include "effects/Overlay.h"
#include "dialogs/CertificateDetails.h"

#include <memory>

KeyDialog::KeyDialog( const CKey &k, QWidget *parent )
: QDialog( parent )
{
Ui::KeyDialog *d = new Ui::KeyDialog;
auto d = std::make_unique<Ui::KeyDialog>();
d->setupUi(this);
#if defined (Q_OS_WIN)
d->buttonLayout->setDirection(QBoxLayout::RightToLeft);
#endif
setWindowFlags( Qt::Dialog | Qt::CustomizeWindowHint );
setWindowFlag(Qt::CustomizeWindowHint);
new Overlay(this, parent->topLevelWidget());

QFont condensed = Styles::font(Styles::Condensed, 12);
Expand All @@ -46,31 +48,27 @@ KeyDialog::KeyDialog( const CKey &k, QWidget *parent )
d->view->setHeaderLabels({tr("Attribute"), tr("Value")});

connect(d->close, &QPushButton::clicked, this, &KeyDialog::accept);
connect(d->showCert, &QPushButton::clicked, this, [=] {
CertificateDetails::showCertificate(SslCertificate(k.cert), this);
connect(d->showCert, &QPushButton::clicked, this, [this, cert=k.cert] {
CertificateDetails::showCertificate(cert, this);
});

auto addItem = [&](const QString &parameter, const QString &value) {
QTreeWidgetItem *i = new QTreeWidgetItem(d->view);
if(value.isEmpty())
return;
auto *i = new QTreeWidgetItem(d->view);
i->setText(0, parameter);
i->setText(1, value);
d->view->addTopLevelItem(i);
};

addItem(tr("Recipient"), k.recipient);
if(!k.method.isEmpty())
addItem(tr("Crypto method"), k.method);
if(!k.agreement.isEmpty())
addItem(tr("Agreement method"), k.agreement);
if(!k.derive.isEmpty())
addItem(tr("Key derivation method"), k.derive);
if(!k.concatDigest.isEmpty())
addItem(tr("ConcatKDF digest method"), k.concatDigest);
//addItem( tr("ID"), k.id );
addItem(tr("Crypto method"), k.method);
addItem(tr("Agreement method"), k.agreement);
addItem(tr("Key derivation method"), k.derive);
addItem(tr("ConcatKDF digest method"), k.concatDigest);
addItem(tr("Expiry date"), k.cert.expiryDate().toLocalTime().toString(QStringLiteral("dd.MM.yyyy hh:mm:ss")));
addItem(tr("Issuer"), SslCertificate(k.cert).issuerInfo(QSslCertificate::CommonName));
d->view->resizeColumnToContents( 0 );
if(!k.agreement.isEmpty())
adjustSize();
delete d;
}

0 comments on commit 5ea92a9

Please sign in to comment.