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 <victortoso@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Victor Toso 2018-08-30 13:51:17 +02:00
parent 71dc30571e
commit 7ffb7f9cf4

View File

@ -256,9 +256,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);
}