mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Ensure that YubiKey is only polled once, even if showEvent() is called twice
This commit is contained in:
parent
51b42bc7b8
commit
f6933a8868
@ -95,11 +95,16 @@ void DatabaseOpenWidget::showEvent(QShowEvent* event)
|
||||
m_ui->editPassword->setFocus();
|
||||
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
||||
connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
|
||||
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
||||
// showEvent() may be called twice, so make sure we are only polling once
|
||||
if (!m_yubiKeyBeingPolled) {
|
||||
connect(YubiKey::instance(), SIGNAL(detected(int, bool)), SLOT(yubikeyDetected(int, bool)),
|
||||
Qt::QueuedConnection);
|
||||
connect(YubiKey::instance(), SIGNAL(detectComplete()), SLOT(yubikeyDetectComplete()), Qt::QueuedConnection);
|
||||
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
||||
|
||||
pollYubikey();
|
||||
pollYubikey();
|
||||
m_yubiKeyBeingPolled = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -110,6 +115,7 @@ void DatabaseOpenWidget::hideEvent(QHideEvent* event)
|
||||
#ifdef WITH_XC_YUBIKEY
|
||||
// Don't listen to any Yubikey events if we are hidden
|
||||
disconnect(YubiKey::instance(), 0, this, 0);
|
||||
m_yubiKeyBeingPolled = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -311,10 +317,12 @@ void DatabaseOpenWidget::yubikeyDetectComplete()
|
||||
m_ui->checkChallengeResponse->setEnabled(true);
|
||||
m_ui->buttonRedetectYubikey->setEnabled(true);
|
||||
m_ui->yubikeyProgress->setVisible(false);
|
||||
m_yubiKeyBeingPolled = false;
|
||||
}
|
||||
|
||||
void DatabaseOpenWidget::noYubikeyFound()
|
||||
{
|
||||
m_ui->buttonRedetectYubikey->setEnabled(true);
|
||||
m_ui->yubikeyProgress->setVisible(false);
|
||||
m_yubiKeyBeingPolled = false;
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ protected:
|
||||
QString m_filename;
|
||||
|
||||
private:
|
||||
bool m_yubiKeyBeingPolled = false;
|
||||
Q_DISABLE_COPY(DatabaseOpenWidget)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user