From 1ad9c1257b9ca3b8345666824f79c4416fab144e Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Tue, 13 Oct 2020 23:23:18 -0400 Subject: [PATCH] Fix crash when toggling capslock rapidly * Fix #5543 - Only check caps lock state when key is pressed/released or widget is focused. --- src/gui/PasswordEdit.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/PasswordEdit.cpp b/src/gui/PasswordEdit.cpp index 943164d4c..b43f5c623 100644 --- a/src/gui/PasswordEdit.cpp +++ b/src/gui/PasswordEdit.cpp @@ -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); @@ -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(); } } }