[gtk/image-loading] contentserializer: avoid an unnecessary check



commit 4c49733afcd1b2f102429ab2765b6fc53e428dc2
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Sep 13 21:31:49 2021 -0400

    contentserializer: avoid an unnecessary check
    
    gdk_save_png/tiff don't fail.

 gdk/gdkcontentserializer.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
---
diff --git a/gdk/gdkcontentserializer.c b/gdk/gdkcontentserializer.c
index 316f6ad9c0..e0bf34bd53 100644
--- a/gdk/gdkcontentserializer.c
+++ b/gdk/gdkcontentserializer.c
@@ -688,6 +688,8 @@ serialize_texture_in_thread (GTask        *task,
   GBytes *bytes = NULL;
   GError *error = NULL;
   gboolean result = FALSE;
+  GInputStream *input;
+  gssize spliced;
 
   value = gdk_content_serializer_get_value (serializer);
   texture = g_value_get_object (value);
@@ -699,25 +701,16 @@ serialize_texture_in_thread (GTask        *task,
   else
     g_assert_not_reached ();
 
-  if (bytes)
-    {
-      GInputStream *input = g_memory_input_stream_new_from_bytes (bytes);
-      gssize spliced;
-
-      spliced = g_output_stream_splice (gdk_content_serializer_get_output_stream (serializer),
-                                        input,
-                                        G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
-                                        gdk_content_serializer_get_cancellable (serializer),
-                                        &error);
-      g_object_unref (input);
-      g_bytes_unref (bytes);
-
-      result = spliced != -1;
-    }
-  else
-    g_set_error_literal (&error,
-                         G_IO_ERROR, G_IO_ERROR_FAILED,
-                         "Saving png failed");
+  input = g_memory_input_stream_new_from_bytes (bytes);
+  spliced = g_output_stream_splice (gdk_content_serializer_get_output_stream (serializer),
+                                    input,
+                                    G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE,
+                                    gdk_content_serializer_get_cancellable (serializer),
+                                    &error);
+  g_object_unref (input);
+  g_bytes_unref (bytes);
+
+  result = spliced != -1;
 
   if (result)
     g_task_return_boolean (task, result);


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