[pim/libkleo/gpg4win/gpd-5.2] src/utils: Simplify code for finding sender user ID

Ingo Klöcker <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 73c11c98c24e6c2d5595f8fc7be9c761b2f6d722 by Ingo Klöcker, on behalf of Ingo Klöcker.
Committed on 30/07/2026 at 09:36.
Pushed by kloecker into branch 'gpg4win/gpd-5.2'.

Simplify code for finding sender user ID

We can safely assume that a not-null key always has a not-null primary
user ID.

GnuPG-bug-id: 7786
(cherry picked from commit d441b1b0522d6b218d472b663be6a19ae13956ed)

M  +3    -7    src/utils/formatting.cpp

https://invent.kde.org/pim/libkleo/-/commit/73c11c98c24e6c2d5595f8fc7be9c761b2f6d722

diff --git a/src/utils/formatting.cpp b/src/utils/formatting.cpp
index 5479137a..3d0f1fc6 100644
--- a/src/utils/formatting.cpp
+++ b/src/utils/formatting.cpp
@@ -1653,14 +1653,10 @@ QString Kleo::Formatting::prettySignature(const GpgME::Signature &sig, const QSt
     if (!sender.isEmpty()) {
         senderUid = findUserIDByMailbox(key, sender);
     }
-    if (senderUid.isNull()) {
-        for (int i = 0, count = key.userIDs().size(); i < count; i++) {
-            senderUid = key.userID(i);
-            if (!senderUid.isNull()) {
-                break;
-            }
-        }
+    if (senderUid.isNull() && !key.isNull()) {
+        senderUid = key.userID(0);
     }
+
     const QString text = formatSigningInformation(sig, key, senderUid) + QLatin1StringView("<br/>");
 
     // Green
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.