Fix multiple TOTP issues, resolves #1360

- Fix crash when deleting TOTP entry
- Fix memory leak when selecting TOTP entries
- Fix TOTP update timeout on DetailsWidget
- Fix TOTP settings attributes not being applied before first call to totpSeed()
This commit is contained in:
Janek Bevendorff 2018-01-22 21:42:22 +01:00
parent 28ebdb72a0
commit 0f5307437c
No known key found for this signature in database
GPG key ID: 2FDEB0D40BCA5E11
6 changed files with 54 additions and 47 deletions

View file

@ -20,33 +20,24 @@
#include "ui_TotpDialog.h"
#include "core/Config.h"
#include "core/Entry.h"
#include "gui/DatabaseWidget.h"
#include "gui/Clipboard.h"
#include <QTimer>
#include <QDateTime>
#include <QPushButton>
TotpDialog::TotpDialog(DatabaseWidget* parent, Entry* entry)
: QDialog(parent)
, m_ui(new Ui::TotpDialog())
, m_totpUpdateTimer(new QTimer(entry))
, m_entry(entry)
{
m_entry = entry;
m_parent = parent;
m_step = m_entry->totpStep();
m_ui->setupUi(this);
m_step = m_entry->totpStep();
uCounter = resetCounter();
updateProgressBar();
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar()));
connect(timer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
timer->start(m_step * 10);
connect(m_totpUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProgressBar()));
connect(m_totpUpdateTimer, SIGNAL(timeout()), this, SLOT(updateSeconds()));
m_totpUpdateTimer->start(m_step * 10);
updateTotp();
setAttribute(Qt::WA_DeleteOnClose);
@ -61,7 +52,7 @@ void TotpDialog::copyToClipboard()
{
clipboard()->setText(m_entry->totp());
if (config()->get("MinimizeOnCopy").toBool()) {
m_parent->window()->showMinimized();
qobject_cast<DatabaseWidget*>(parent())->window()->showMinimized();
}
}
@ -101,4 +92,7 @@ double TotpDialog::resetCounter()
TotpDialog::~TotpDialog()
{
if (m_totpUpdateTimer) {
delete m_totpUpdateTimer;
}
}