[Spice-devel] [PATCH spice-gtk] Spicy: cancel file transfer when dialog is closed

Jonathon Jongsma jjongsma at redhat.com
Tue Feb 7 21:09:29 UTC 2017


Clicking the 'X' to close the file transfer dialog did not actually
cancel the ongoing file transfer, and resulted in a bunch of critical
warnings on the terminal. Make the delete-event explicitly cancel all
ongoing file transfers.
---
 tools/spicy.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/spicy.c b/tools/spicy.c
index c502428..9279f9b 100644
--- a/tools/spicy.c
+++ b/tools/spicy.c
@@ -1487,6 +1487,14 @@ static void transfer_task_finished(SpiceFileTransferTask *task, GError *error, s
         gtk_widget_hide(conn->transfer_dialog);
 }
 
+static gboolean dialog_delete_cb(GtkWidget *widget,
+                                 GdkEvent *event G_GNUC_UNUSED,
+                                 gpointer user_data G_GNUC_UNUSED)
+{
+    gtk_dialog_response(GTK_DIALOG(widget), GTK_RESPONSE_CANCEL);
+    return TRUE;
+}
+
 static void dialog_response_cb(GtkDialog *dialog,
                                gint response_id,
                                gpointer user_data)
@@ -1580,6 +1588,8 @@ static void spice_connection_add_task(spice_connection *conn, SpiceFileTransferT
         gtk_window_set_resizable(GTK_WINDOW(conn->transfer_dialog), FALSE);
         g_signal_connect(conn->transfer_dialog, "response",
                          G_CALLBACK(dialog_response_cb), conn);
+        g_signal_connect(conn->transfer_dialog, "delete-event",
+                         G_CALLBACK(dialog_delete_cb), conn);
     }
     gtk_widget_show(conn->transfer_dialog);
     content = gtk_dialog_get_content_area(GTK_DIALOG(conn->transfer_dialog));
-- 
2.9.3



More information about the Spice-devel mailing list