[PATCH virt-viewer] !fixup Show failed file transfers

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

 



---

Here's a possible solution. I don't think that a "continue" if the filename is
NULL would work well since then you might have an error message with non files
listed. So here I just display the task ID. Not sure whether that makes sense
or not. I could instead use something like "(unnamed file)". Or we could just
ignore the scenario and let gcc print "(null)" for this unexpected case.

 src/virt-viewer-file-transfer-dialog.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/virt-viewer-file-transfer-dialog.c b/src/virt-viewer-file-transfer-dialog.c
index 626a26a..c016e64 100644
--- a/src/virt-viewer-file-transfer-dialog.c
+++ b/src/virt-viewer-file-transfer-dialog.c
@@ -178,10 +178,18 @@ static gboolean hide_transfer_dialog(gpointer data)
     if (self->priv->failed) {
         GSList *sl;
         GString *msg = g_string_new("");
+        GtkWidget *dialog;
 
         for (sl = self->priv->failed; sl != NULL; sl = g_slist_next(sl)) {
             SpiceFileTransferTask *failed_task = sl->data;
             gchar *filename = spice_file_transfer_task_get_filename(failed_task);
+            if (filename == NULL) {
+                guint id;
+
+                g_object_get(failed_task, "id", &id, NULL);
+                g_warning("Unable to get filename of failed transfer");
+                filename = g_strdup_printf("(task #%u)", id);
+            }
 
             g_string_append_printf(msg, "\n%s", filename);
             g_free(filename);
@@ -189,10 +197,10 @@ static gboolean hide_transfer_dialog(gpointer data)
         g_slist_free_full(self->priv->failed, g_object_unref);
         self->priv->failed = NULL;
 
-        GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(self), 0, GTK_MESSAGE_ERROR,
-                                                   GTK_BUTTONS_OK,
-                                                   _("An error caused following file transfers to fail:\n%s"),
-                                                   msg->str);
+        dialog = gtk_message_dialog_new(GTK_WINDOW(self), 0, GTK_MESSAGE_ERROR,
+                                        GTK_BUTTONS_OK,
+                                        _("An error caused following file transfers to fail:%s"),
+                                        msg->str);
         g_string_free(msg, TRUE);
         g_signal_connect(dialog, "response", G_CALLBACK(error_dialog_response), NULL);
         gtk_widget_show(dialog);
-- 
2.7.4

_______________________________________________
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