From 1397ef78ac43e971cef317893f9fe597bf7074ed Mon Sep 17 00:00:00 2001 From: Victor Toso Date: Thu, 30 Aug 2018 13:51:17 +0200 Subject: [PATCH] app: Always add guest name comment Even when the user adds comments, we should place the guest's name unless it is present already. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1623756 Signed-off-by: Victor Toso Acked-by: Christophe Fergeau (cherry picked from commit 7ffb7f9cf485f6eefacccf6b20167b0d67521ebb) --- src/virt-viewer-app.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index e90afe8..6f17842 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -258,9 +258,13 @@ virt_viewer_app_save_config(VirtViewerApp *self) if (error) { g_debug("Unable to get comment from key file: %s", error->message); g_clear_error(&error); - } else { - if (!comment || *comment == '\0') - g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL); + } + + if (comment == NULL || + (comment != NULL && g_strstr_len(comment, -1, priv->guest_name) == NULL)) { + /* Note that this function appends the guest's name string as last + * comment in case there were comments there already */ + g_key_file_set_comment(priv->config, priv->uuid, NULL, priv->guest_name, NULL); } g_free(comment); }