[Spice-devel] [PATCH spice-gtk 09/15] channel-main: Allow calling file_xfer_close_cb with a NULL object

Hans de Goede hdegoede at redhat.com
Sat Mar 9 03:06:29 PST 2013


So that it can used for cleanup before we've a file_stream.

Note this also gets rid of the weird double initialization of the local
stream variable.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/channel-main.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 1b314ac..cd5b162 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -1530,17 +1530,18 @@ static void file_xfer_close_cb(GObject      *object,
 {
     GSimpleAsyncResult *res;
     SpiceFileXferTask *task;
-    GInputStream *stream = G_INPUT_STREAM(object);
     GError *error = NULL;
 
-    stream = G_INPUT_STREAM(object);
     task = user_data;
 
-    g_input_stream_close_finish(stream, close_res, &error);
-    if (error) {
-        /* This error dont need to report to user, just print a log */
-        SPICE_DEBUG("close file error: %s", error->message);
-        g_clear_error(&error);
+    if (object) {
+        GInputStream *stream = G_INPUT_STREAM(object);
+        g_input_stream_close_finish(stream, close_res, &error);
+        if (error) {
+            /* This error dont need to report to user, just print a log */
+            SPICE_DEBUG("close file error: %s", error->message);
+            g_clear_error(&error);
+        }
     }
 
     /* Notify to user that files have been transferred or something error
-- 
1.8.1.4



More information about the Spice-devel mailing list