Fix crash when toggling capslock rapidly

* Fix #5543 - Only check caps lock state when key is pressed/released or widget is focused.
This commit is contained in:
Jonathan White 2020-10-13 23:23:18 -04:00
parent a55bb39f20
commit 1ad9c1257b

View File

@ -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();
}
}
}