Commit ee47e24e authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Delay showing "no key" error while a lookup is running

This prevents a "no key" error from being displayed briefly while a key
lookup is running in the background. The error will be shown if the
lookup wasn't successful or if no lookup was started in the first place.

GnuPG-bug-id: 5945
parent e7daba64
Pipeline #168606 passed with stage
in 1 minute and 52 seconds
......@@ -346,11 +346,14 @@ void CertificateLineEdit::Private::editChanged()
void CertificateLineEdit::Private::editFinished()
{
// perform a first update with the "editing in progress" flag still set
updateKey();
mEditingInProgress = false;
checkLocate();
// perform another update with the "editing in progress" flag cleared
// after a key locate may have been started; this makes sure that displaying
// an error is delayed until the key locate job has finished
updateKey();
if (mStatus == Status::None) {
checkLocate();
}
}
void CertificateLineEdit::Private::checkLocate()
......@@ -393,6 +396,10 @@ void CertificateLineEdit::Private::onLocateJobResult(QGpgME::Job *job, const QSt
mLocateJob.clear();
if (!keys.empty() && !keys.front().isNull()) {
KeyCache::mutableInstance()->insert(keys.front());
// inserting the key implicitly triggers an update
} else {
// explicitly trigger an update to display "no key" error
updateKey();
}
}
......@@ -504,7 +511,7 @@ QIcon CertificateLineEdit::Private::statusIcon() const
}
case Status::None:
case Status::Ambiguous:
if (mEditingInProgress) {
if (mEditingInProgress || mLocateJob) {
return QIcon::fromTheme(QStringLiteral("emblem-question"));
} else {
return QIcon::fromTheme(QStringLiteral("emblem-error"));
......@@ -561,7 +568,7 @@ void CertificateLineEdit::Private::updateErrorLabel()
if (newErrorMessage == currentErrorMessage) {
return;
}
if (currentErrorMessage.isEmpty() && mEditingInProgress) {
if (currentErrorMessage.isEmpty() && (mEditingInProgress || mLocateJob)) {
// delay showing the error message until editing is finished, so that we
// do not annoy the user with an error message while they are still
// entering the recipient;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment