[Spice-devel] [spice-gtk] option: Allow multiple options in --disable-effects
Marc-André Lureau
mlureau at redhat.com
Tue Apr 23 10:21:52 PDT 2013
ack
----- Mensaje original -----
> Commit 82c367 added checks that the value passed to --disable-effects
> is valid, but it does not take into account that it's perfectly valid
> to pass multiple values separated by commas. This commit splits
> the value passed to --disable-effects and checks each component separatey.
>
> Fixes rhbz#955277
> ---
> gtk/spice-option.c | 40 ++++++++++++++++++++--------------------
> 1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/gtk/spice-option.c b/gtk/spice-option.c
> index 4bda520..5f7c803 100644
> --- a/gtk/spice-option.c
> +++ b/gtk/spice-option.c
> @@ -27,7 +27,7 @@
> #include "spice-channel-priv.h"
> #include "usb-device-manager.h"
>
> -static gchar *disable_effects = NULL;
> +static GStrv disable_effects = NULL;
> static gint color_depth = 0;
> static char *ca_file = NULL;
> static char *host_subject = NULL;
> @@ -85,22 +85,26 @@ error:
> static gboolean parse_disable_effects(const gchar *option_name, const gchar
> *value,
> gpointer data, GError **error)
> {
> -
> - if ((g_strcmp0(value, "wallpaper") != 0)
> - && (g_strcmp0(value, "font-smooth") != 0)
> - && (g_strcmp0(value, "animation") != 0)
> - && (g_strcmp0(value, "all") != 0)) {
> - /* Translators: do not translate 'wallpaper', 'font-smooth',
> - * 'animation', 'all' as the user must use these values with the
> - * --spice-disable-effects command line option
> - */
> - g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
> - _("invalid effect name (%s), must be 'wallpaper',
> 'font-smooth', 'animation' or 'all'"), value);
> - return FALSE;
> + GStrv it;
> +
> + disable_effects = g_strsplit(value, ",", -1);
> + for (it = disable_effects; *it != NULL; it++) {
> + if ((g_strcmp0(*it, "wallpaper") != 0)
> + && (g_strcmp0(*it, "font-smooth") != 0)
> + && (g_strcmp0(*it, "animation") != 0)
> + && (g_strcmp0(*it, "all") != 0)) {
> + /* Translators: do not translate 'wallpaper', 'font-smooth',
> + * 'animation', 'all' as the user must use these values with the
> + * --spice-disable-effects command line option
> + */
> + g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
> + _("invalid effect name (%s), must be 'wallpaper',
> 'font-smooth', 'animation' or 'all'"), *it);
> + g_strfreev(disable_effects);
> + disable_effects = NULL;
> + return FALSE;
> + }
> }
>
> - disable_effects = g_strdup(value);
> -
> return TRUE;
> }
>
> @@ -222,11 +226,7 @@ void spice_set_session_option(SpiceSession *session)
> }
>
> if (disable_effects) {
> - GStrv effects;
> - effects = g_strsplit(disable_effects, ",", -1);
> - if (effects)
> - g_object_set(session, "disable-effects", effects, NULL);
> - g_strfreev(effects);
> + g_object_set(session, "disable-effects", disable_effects, NULL);
> }
>
> if (secure_channels) {
> --
> 1.8.1.4
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list