From da5343a9d2c8c0ca6431162aac4bd5c73b4ae6dd Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Fri, 16 Dec 2016 19:09:13 +0100 Subject: [PATCH] cpp: Ensure that hasSecret is correct after update * lang/cpp/src/key.cpp (Key::update): Check for a secret key first before listing public keys. -- This is a performance delay but the update should only be called in a non gui thread anyway. The information if we have the secret key for this key is important to provide after update. --- lang/cpp/src/key.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lang/cpp/src/key.cpp b/lang/cpp/src/key.cpp index d621a81e..4f7ec54b 100644 --- a/lang/cpp/src/key.cpp +++ b/lang/cpp/src/key.cpp @@ -341,7 +341,12 @@ void Key::update() KeyListMode::Validate | KeyListMode::WithTofu); Error err; - auto newKey = ctx->key(primaryFingerprint(), err, hasSecret()); + auto newKey = ctx->key(primaryFingerprint(), err, true); + // Not secret so we get the information from the pubring. + if (newKey.isNull()) + { + newKey = ctx->key(primaryFingerprint(), err, false); + } delete ctx; if (err) { return;