Skip to content

Commit

Permalink
Clear password field when widget is hidden, resolves #2502
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed Nov 23, 2018
1 parent 6748423 commit 07862f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
disconnect(YubiKey::instance(), nullptr, this, nullptr);
m_yubiKeyBeingPolled = false;
#endif

if (isVisible()) {
return;
}

clearForms();
}

void DatabaseOpenWidget::load(const QString& filename)
Expand All @@ -148,8 +154,9 @@ void DatabaseOpenWidget::load(const QString& filename)

void DatabaseOpenWidget::clearForms()
{
m_ui->editPassword->clear();
m_ui->editPassword->setText("");
m_ui->comboKeyFile->clear();
m_ui->comboKeyFile->setEditText("");
m_ui->checkPassword->setChecked(true);
m_ui->checkKeyFile->setChecked(false);
m_ui->checkChallengeResponse->setChecked(false);
Expand Down Expand Up @@ -225,7 +232,7 @@ void DatabaseOpenWidget::openDatabase()
} else {
m_ui->messageWidget->showMessage(tr("Unable to open the database:\n%1").arg(error),
MessageWidget::Error);
m_ui->editPassword->clear();
m_ui->editPassword->setText("");

#ifdef WITH_XC_TOUCHID
// unable to unlock database, reset TouchID for the current database
Expand Down
2 changes: 1 addition & 1 deletion src/gui/PasswordEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void PasswordEdit::setShowPassword(bool show)
setText(m_basePasswordEdit->text());
} else {
// This fix a bug when the QLineEdit is disabled while switching config
if (isEnabled() == false) {
if (!isEnabled()) {
setEnabled(true);
setReadOnly(false);
}
Expand Down
3 changes: 2 additions & 1 deletion src/gui/PasswordEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define KEEPASSX_PASSWORDEDIT_H

#include <QLineEdit>
#include <QPointer>

class PasswordEdit : public QLineEdit
{
Expand All @@ -46,7 +47,7 @@ private slots:
private:
bool passwordsEqual() const;

PasswordEdit* m_basePasswordEdit;
QPointer<PasswordEdit> m_basePasswordEdit;
};

#endif // KEEPASSX_PASSWORDEDIT_H
1 change: 1 addition & 0 deletions src/gui/entry/EditEntryWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <QModelIndex>
#include <QScopedPointer>
#include <QButtonGroup>
#include <QPointer>

#include "config-keepassx.h"
#include "gui/EditWidget.h"
Expand Down

0 comments on commit 07862f2

Please sign in to comment.