[rhythmbox] chunkloader: hold a ref to keep the object alive at eof/on error



commit fd399023cd6c289a9b259023eea170ee44302dbd
Author: Jonathan Matthew <jonathan d14n org>
Date:   Fri Mar 29 12:39:33 2013 +1000

    chunkloader: hold a ref to keep the object alive at eof/on error
    
    refcounting bugs elsewhere apparently hid this until recently, but
    if the callback drops the last reference to the object, it clearly
    needs to keep itself alive for long enough to clean up.

 lib/rb-chunk-loader.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/lib/rb-chunk-loader.c b/lib/rb-chunk-loader.c
index ff51825..6b8354d 100644
--- a/lib/rb-chunk-loader.c
+++ b/lib/rb-chunk-loader.c
@@ -72,6 +72,9 @@ stream_close_cb (GObject *obj, GAsyncResult *res, gpointer data)
                rb_debug ("unable to close input stream: %s", error->message);
                g_clear_error (&error);
        }
+
+       /* release reference taken before calling cleanup() */
+       g_object_unref (obj);
 }
 
 static void
@@ -95,10 +98,12 @@ stream_read_async_cb (GObject *obj, GAsyncResult *res, gpointer data)
                                           &loader->priv->error);
        if (done == -1) {
                rb_debug ("error reading from stream: %s", loader->priv->error->message);
+               g_object_ref (loader);
                loader->priv->callback (loader, NULL, 0, loader->priv->callback_data);
                cleanup (loader);
        } else if (done == 0) {
-               rb_debug ("reached end up input stream");
+               rb_debug ("reached end of input stream");
+               g_object_ref (loader);
                loader->priv->callback (loader, NULL, 0, loader->priv->callback_data);
                cleanup (loader);
        } else {


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