mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-24 15:25:31 -04:00
Ensure that YubiKey is only polled once, even if showEvent() is called twice
This commit is contained in:
parent
51b42bc7b8
commit
f6933a8868
2 changed files with 13 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue