Re: [PATCH v2 virt-viewer] Display warning if UI file fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ACK (I assume you have checked it's G_FILE_ERROR_NOENT which is returned
when the ui file can't be found ?)

Christophe

On Tue, Feb 11, 2014 at 12:03:50PM -0600, Jonathon Jongsma wrote:
> When trying to load ui files, we try to find the file in several directories.
> If a file is not found in one directory, try to load it from the next directory.
> However, if a file is found in a directory but we are not able to load it (e.g.
> due to unsupported versions of glade used to generate it, etc), we should print
> a warning to the terminal to help the developer debug the issue.
> 
> This is an unexpected failure (whereas not finding the file in that directory at
> all is an 'expected' failure).
> ---
> 
> check for G_FILE_ERROR_NOENT as suggested by Christophe
> 
> src/virt-viewer-util.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> index 9deddad..4c60583 100644
> --- a/src/virt-viewer-util.c
> +++ b/src/virt-viewer-util.c
> @@ -58,7 +58,12 @@ GtkBuilder *virt_viewer_util_load_ui(const char *name)
>          gtk_builder_add_from_file(builder, name, &error);
>      } else {
>          gchar *path = g_build_filename(PACKAGE_DATADIR, "ui", name, NULL);
> -        gboolean success = (gtk_builder_add_from_file(builder, path, NULL) != 0);
> +        gboolean success = (gtk_builder_add_from_file(builder, path, &error) != 0);
> +        if (error) {
> +            if (!(error->domain == G_FILE_ERROR && error->code == G_FILE_ERROR_NOENT))
> +                g_warning("Failed to add ui file '%s': %s", path, error->message);
> +            g_clear_error(&error);
> +        }
>          g_free(path);
>  
>          if (!success) {
> -- 
> 1.8.5.3
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/virt-tools-list

Attachment: pgptIC4EcYfvt.pgp
Description: PGP signature

_______________________________________________
virt-tools-list mailing list
virt-tools-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/virt-tools-list

[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux