From 2bd1d5d73749d9a76caf4cb1228d0e95f1ea0252 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Mon, 16 Feb 2009 09:33:39 +0000 Subject: [PATCH] =?utf8?q?Bug=20571598=20=E2=80=93=20GAsyncResult=20with?= =?utf8?q?=20NULL=20gobject?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2009-02-16 Ryan Lortie Bug 571598 – GAsyncResult with NULL gobject * gsimpleasyncresult.c: remove various assertions and add some checks to allow for a NULL source_object in GSimpleAsyncResult. svn path=/trunk/; revision=7864 --- gio/ChangeLog | 7 +++++++ gio/gsimpleasyncresult.c | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index fb38aff4..f49c4b65 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,10 @@ +2009-02-16 Ryan Lortie + + Bug 571598 – GAsyncResult with NULL gobject + + * gsimpleasyncresult.c: remove various assertions and add some checks + to allow for a NULL source_object in GSimpleAsyncResult. + 2009-02-11 Matthias Clasen Bug 541225 – Can't compile gio on AIX : duplicate case value in diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c index 7664fd3c..d5c3e7bd 100644 --- a/gio/gsimpleasyncresult.c +++ b/gio/gsimpleasyncresult.c @@ -179,7 +179,8 @@ g_simple_async_result_init (GSimpleAsyncResult *simple) /** * g_simple_async_result_new: - * @source_object: a #GObject the asynchronous function was called with. + * @source_object: a #GObject the asynchronous function was called with, + * or %NULL. * @callback: a #GAsyncReadyCallback. * @user_data: user data passed to @callback. * @source_tag: the asynchronous function. @@ -196,11 +197,14 @@ g_simple_async_result_new (GObject *source_object, { GSimpleAsyncResult *simple; - g_return_val_if_fail (G_IS_OBJECT (source_object), NULL); + g_return_val_if_fail (!source_object || G_IS_OBJECT (source_object), NULL); simple = g_object_new (G_TYPE_SIMPLE_ASYNC_RESULT, NULL); simple->callback = callback; - simple->source_object = g_object_ref (source_object); + if (source_object) + simple->source_object = g_object_ref (source_object); + else + simple->source_object = NULL; simple->user_data = user_data; simple->source_tag = source_tag; @@ -209,7 +213,7 @@ g_simple_async_result_new (GObject *source_object, /** * g_simple_async_result_new_from_error: - * @source_object: a #GObject. + * @source_object: a #GObject, or %NULL. * @callback: a #GAsyncReadyCallback. * @user_data: user data passed to @callback. * @error: a #GError location. @@ -226,7 +230,7 @@ g_simple_async_result_new_from_error (GObject *source_object, { GSimpleAsyncResult *simple; - g_return_val_if_fail (G_IS_OBJECT (source_object), NULL); + g_return_val_if_fail (!source_object || G_IS_OBJECT (source_object), NULL); simple = g_simple_async_result_new (source_object, callback, @@ -238,7 +242,7 @@ g_simple_async_result_new_from_error (GObject *source_object, /** * g_simple_async_result_new_error: - * @source_object: a #GObject. + * @source_object: a #GObject, or %NULL. * @callback: a #GAsyncReadyCallback. * @user_data: user data passed to @callback. * @domain: a #GQuark. @@ -262,7 +266,7 @@ g_simple_async_result_new_error (GObject *source_object, GSimpleAsyncResult *simple; va_list args; - g_return_val_if_fail (G_IS_OBJECT (source_object), NULL); + g_return_val_if_fail (!source_object || G_IS_OBJECT (source_object), NULL); g_return_val_if_fail (domain != 0, NULL); g_return_val_if_fail (format != NULL, NULL); -- 2.34.1