[virt-tools-list] [PATCH virt-viewer] Fix "Do not ask me again" checkbox settings saving

Hans de Goede hdegoede at redhat.com
Thu Feb 7 19:18:12 UTC 2013


ACK :)

On 02/06/2013 09:23 PM, Marc-André Lureau wrote:
> Based on bug report by Hans:
>
> The code block for saving was below this check:
>
>      if (priv->session) {
>          virt_viewer_session_close(VIRT_VIEWER_SESSION(priv->session));
>          if (priv->connected) {
>              priv->quiting = TRUE;
>              return;
>          }
>      }
>
> Which means it never executes when quiting virt-viewer while conneced, causing
> the "Do not ask me again" checkbox settings to not be saved.
> ---
>   src/virt-viewer-app.c | 39 ++++++++++++++++++++++-----------------
>   1 file changed, 22 insertions(+), 17 deletions(-)
>
> diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
> index f5d78a9..25df5c8 100644
> --- a/src/virt-viewer-app.c
> +++ b/src/virt-viewer-app.c
> @@ -220,15 +220,34 @@ virt_viewer_app_simple_message_dialog(VirtViewerApp *self,
>       g_free(msg);
>   }
>
> -void
> -virt_viewer_app_quit(VirtViewerApp *self)
> +static void
> +virt_viewer_app_save_config(VirtViewerApp *self)
>   {
> +    VirtViewerAppPrivate *priv = self->priv;
>       GError *error = NULL;
> -    gchar *data;
> +    gchar *dir, *data;
> +
> +    dir = g_path_get_dirname(priv->config_file);
> +    if (g_mkdir_with_parents(dir, S_IRWXU) == -1)
> +        g_warning("failed to create config directory");
> +    g_free(dir);
> +
> +    if ((data = g_key_file_to_data(priv->config, NULL, &error)) == NULL ||
> +        !g_file_set_contents(priv->config_file, data, -1, &error)) {
> +        g_warning("Couldn't save configuration: %s", error->message);
> +        g_clear_error(&error);
> +    }
> +    g_free(data);
> +}
>
> +void
> +virt_viewer_app_quit(VirtViewerApp *self)
> +{
>       g_return_if_fail(VIRT_VIEWER_IS_APP(self));
>       VirtViewerAppPrivate *priv = self->priv;
>
> +    virt_viewer_app_save_config(self);
> +
>       if (priv->session) {
>           virt_viewer_session_close(VIRT_VIEWER_SESSION(priv->session));
>           if (priv->connected) {
> @@ -237,20 +256,6 @@ virt_viewer_app_quit(VirtViewerApp *self)
>           }
>       }
>
> -    {
> -        gchar *dir = g_path_get_dirname(priv->config_file);
> -        if (g_mkdir_with_parents(dir, S_IRWXU) == -1)
> -            g_warning("failed to create config directory");
> -        g_free(dir);
> -    }
> -
> -    if ((data = g_key_file_to_data(priv->config, NULL, &error)) == NULL ||
> -        !g_file_set_contents(priv->config_file, data, -1, &error)) {
> -        g_warning("Couldn't save configuration: %s", error->message);
> -        g_clear_error(&error);
> -    }
> -    g_free(data);
> -
>       gtk_main_quit();
>   }
>
>




More information about the virt-tools-list mailing list