[glib] GAsyncInitable: fix subclassibility



commit afe7a2d1368fc8dff0735757c096ded3d540ae42
Author: Dan Winship <danw gnome org>
Date:   Thu Jan 5 13:04:37 2012 -0500

    GAsyncInitable: fix subclassibility
    
    If a class implements GAsyncInitable, and its parent also implements
    it, then the subclass needs to call its parent's init_async() before
    running its own. This was made more complicated by the fact that the
    default init_finish() behavior was handled by the wrapper method
    (which can't be used when making the super call) rather than the
    default implementation itself. Fix that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667375

 gio/gasyncinitable.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/gio/gasyncinitable.c b/gio/gasyncinitable.c
index 0cfde8d..e2264e0 100644
--- a/gio/gasyncinitable.c
+++ b/gio/gasyncinitable.c
@@ -294,7 +294,19 @@ g_async_initable_real_init_finish (GAsyncInitable  *initable,
 				   GAsyncResult    *res,
 				   GError         **error)
 {
-  return TRUE; /* Errors handled by base impl */
+  /* Although g_async_initable_init_finish() does this error handling
+   * as well, we do it here too, so that a class that reimplements
+   * GAsyncInitable can properly run its parent class's implementation
+   * by directly invoking its ->init_async() and ->init_finish().
+   */
+  if (G_IS_SIMPLE_ASYNC_RESULT (res))
+    {
+      GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
+      if (g_simple_async_result_propagate_error (simple, error))
+	return FALSE;
+    }
+
+  return TRUE;
 }
 
 /**



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