[balsa] Object-ref the stream if the caller will unref it



commit 498722a98229f6d3b0b6f5815cfc821ec5438537
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Apr 6 18:04:02 2010 -0400

    Object-ref the stream if the caller will unref it
    
    	* libbalsa/mailbox.c (msg_iterator): object-ref the stream if
    	the caller will unref it.

 ChangeLog          |    5 +++++
 libbalsa/mailbox.c |    8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a806c0e..03f858d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-04-06  Peter Bloomfield
+
+	* libbalsa/mailbox.c (msg_iterator): object-ref the stream if
+	the caller will unref it.
+
 2010-04-05  Peter Bloomfield
 
 	* libbalsa/mailbox_imap.c (multi_append_cb): round size in
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index a2a79ad..be4a732 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -1776,13 +1776,13 @@ static gboolean
 msg_iterator(LibBalsaMessageFlag *flg, GMimeStream **stream, void *arg)
 {
     struct AddMessageData * amd = (struct AddMessageData*)arg;
-    gboolean res = !amd->processed;
+    if (amd->processed)
+        return FALSE;
     amd->processed = TRUE;
     *flg = amd->flags;
-    *stream = amd->stream;
  /* Make sure ::add_messages does not destroy the stream. */
-    if (!res) g_object_ref(amd->stream);
-    return res;
+    *stream = g_object_ref(amd->stream);
+    return TRUE;
 }
 
 gboolean



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