Skip to content

Commit

Permalink
Fix crash when toggling capslock rapidly
Browse files Browse the repository at this point in the history
* Fix keepassxreboot#5543 - Only check caps lock state when key is pressed/released or widget is focused.
  • Loading branch information
droidmonkey committed Oct 15, 2020
1 parent a55bb39 commit 1ad9c12
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gui/PasswordEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ void PasswordEdit::autocompletePassword(const QString& password)

bool PasswordEdit::event(QEvent* event)
{
if (isVisible()) {
if (isVisible()
&& (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease
|| event->type() == QEvent::FocusIn)) {
checkCapslockState();
}
return QLineEdit::event(event);
Expand All @@ -204,7 +206,9 @@ void PasswordEdit::checkCapslockState()

if (newCapslockState) {
QTimer::singleShot(
150, [this]() { QToolTip::showText(mapToGlobal(rect().bottomLeft()), m_capslockAction->text()); });
150, [this] { QToolTip::showText(mapToGlobal(rect().bottomLeft()), m_capslockAction->text()); });
} else if (QToolTip::isVisible()) {
QToolTip::hideText();
}
}
}

0 comments on commit 1ad9c12

Please sign in to comment.