[glib] _simple_async_result_is_valid: allow tag to be NULL



commit ec31612ea00e2babd5d6b02d65966164594a03f8
Author: Will Thompson <will willthompson co uk>
Date:   Fri Aug 13 23:15:27 2010 -0400

    _simple_async_result_is_valid: allow tag to be NULL
    
    Because g_simple_async_report_[g]error_in_idle() don't take a source tag
    parameter, code that uses them can't currently use
    g_simple_async_result_is_valid() (at least, not for the error case).
    
    Bug 602417

 gio/gsimpleasyncresult.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c
index b68684a..dd4df90 100644
--- a/gio/gsimpleasyncresult.c
+++ b/gio/gsimpleasyncresult.c
@@ -735,10 +735,12 @@ g_simple_async_result_run_in_thread (GSimpleAsyncResult     *simple,
  * First, @result is checked to ensure that it is really a
  * #GSimpleAsyncResult.  Second, @source is checked to ensure that it
  * matches the source object of @result.  Third, @source_tag is
- * checked to ensure that it is equal to the source_tag argument given
- * to g_simple_async_result_new() (which, by convention, is a pointer
- * to the _async function corresponding to the _finish function from
- * which this function is called).
+ * checked to ensure that it is either %NULL (as it is when the result was
+ * created by g_simple_async_report_error_in_idle() or
+ * g_simple_async_report_gerror_in_idle()) or equal to the
+ * @source_tag argument given to g_simple_async_result_new() (which, by
+ * convention, is a pointer to the _async function corresponding to the
+ * _finish function from which this function is called).
  *
  * Returns: #TRUE if all checks passed or #FALSE if any failed.
  **/
@@ -764,7 +766,8 @@ g_simple_async_result_is_valid (GAsyncResult *result,
   if (cmp_source != NULL)
     g_object_unref (cmp_source);
 
-  return source_tag == g_simple_async_result_get_source_tag (simple);
+  return source_tag == NULL ||
+         source_tag == g_simple_async_result_get_source_tag (simple);
 }
 
 /**



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