[gtk/wip/otte/for-master: 9/9] contentdeserializer: Fix some API awkwardness




commit 119458f13e6110e470d794b038a9bfdad8b28dd7
Author: Benjamin Otte <otte redhat com>
Date:   Mon Aug 23 07:06:37 2021 +0200

    contentdeserializer: Fix some API awkwardness
    
    Allow uninitialized GValues to be passed. Makes life easier for the
    inspector code I'm writing.

 gdk/gdkcontentdeserializer.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/gdk/gdkcontentdeserializer.c b/gdk/gdkcontentdeserializer.c
index f245b4c350..4959b5af4d 100644
--- a/gdk/gdkcontentdeserializer.c
+++ b/gdk/gdkcontentdeserializer.c
@@ -553,6 +553,8 @@ gdk_content_deserialize_async (GInputStream        *stream,
   Deserializer *deserializer;
 
   g_return_if_fail (G_IS_INPUT_STREAM (stream));
+  g_return_if_fail (mime_type != NULL);
+  g_return_if_fail (G_TYPE_IS_VALUE_TYPE (type));
   g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
   g_return_if_fail (callback != NULL);
 
@@ -591,7 +593,10 @@ gdk_content_deserialize_finish (GAsyncResult  *result,
   g_return_val_if_fail (GDK_IS_CONTENT_DESERIALIZER (result), FALSE);
   g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
   deserializer = GDK_CONTENT_DESERIALIZER (result);
-  g_return_val_if_fail (G_VALUE_HOLDS (value, G_VALUE_TYPE (&deserializer->value)), FALSE);
+  if (G_VALUE_TYPE (value) == 0)
+    g_value_init (value, G_VALUE_TYPE (&deserializer->value));
+  else
+    g_return_val_if_fail (G_VALUE_HOLDS (value, G_VALUE_TYPE (&deserializer->value)), FALSE);
 
   if (deserializer->error)
     {


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