[evolution-data-server] Don't close base stream when destroying a CamelFilterOutputStream.



commit 86e84cd7c72410ac8f42d2bb98b0b669ed690665
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Mar 10 11:27:41 2014 -0400

    Don't close base stream when destroying a CamelFilterOutputStream.
    
    GFilterOutputStream, from which CamelFilterOutputStream is derived,
    defaults to closing its base stream when the instance is finalized.
    
    That makes sense in the general case, but CamelFilterOutputStreams are
    usually temporary wrappers on a more permanent base stream, so we need
    to remember to override the default "close-base-stream" property value.
    
    I was tempted to just make CamelFilterOutputStream override the default
    automatically, but I decided against it because my long term plan is to
    drop CamelFilterOutputStream for GConverterOutputStream which also does
    not override the "close-base-stream" default.  The closer the semantics
    of the two classes match, the easier porting will be in the future.

 camel/camel-data-wrapper.c                 |    8 ++++++++
 camel/camel-mime-part.c                    |    6 ++++++
 camel/providers/imapx/camel-imapx-server.c |    3 +++
 3 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index c454e46..22dc978 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -307,6 +307,8 @@ data_wrapper_decode_to_output_stream_sync (CamelDataWrapper *data_wrapper,
                                CAMEL_MIME_FILTER_BASIC_BASE64_DEC);
                        filter_stream = camel_filter_output_stream_new (
                                output_stream, filter);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (filter_stream), FALSE);
                        g_object_unref (filter);
                        break;
                case CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE:
@@ -314,6 +316,8 @@ data_wrapper_decode_to_output_stream_sync (CamelDataWrapper *data_wrapper,
                                CAMEL_MIME_FILTER_BASIC_QP_DEC);
                        filter_stream = camel_filter_output_stream_new (
                                output_stream, filter);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (filter_stream), FALSE);
                        g_object_unref (filter);
                        break;
                case CAMEL_TRANSFER_ENCODING_UUENCODE:
@@ -321,6 +325,8 @@ data_wrapper_decode_to_output_stream_sync (CamelDataWrapper *data_wrapper,
                                CAMEL_MIME_FILTER_BASIC_UU_DEC);
                        filter_stream = camel_filter_output_stream_new (
                                output_stream, filter);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (filter_stream), FALSE);
                        g_object_unref (filter);
                        break;
                default:
@@ -343,6 +349,8 @@ data_wrapper_decode_to_output_stream_sync (CamelDataWrapper *data_wrapper,
                        CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
                temp_stream = camel_filter_output_stream_new (
                        filter_stream, filter);
+               g_filter_output_stream_set_close_base_stream (
+                       G_FILTER_OUTPUT_STREAM (temp_stream), FALSE);
                g_object_unref (filter);
 
                g_object_unref (filter_stream);
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index fbb783c..088584c 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -898,6 +898,8 @@ mime_part_write_to_output_stream_sync (CamelDataWrapper *dw,
                                content_charset, part_charset);
                        temp_stream = camel_filter_output_stream_new (
                                filter_stream, charenc);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (temp_stream), FALSE);
                        g_object_unref (charenc);
 
                        g_object_unref (filter_stream);
@@ -915,6 +917,8 @@ mime_part_write_to_output_stream_sync (CamelDataWrapper *dw,
                                CAMEL_MIME_FILTER_CRLF_MODE_CRLF_ONLY);
                        temp_stream = camel_filter_output_stream_new (
                                filter_stream, crlf);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (temp_stream), FALSE);
                        g_object_unref (crlf);
 
                        g_object_unref (filter_stream);
@@ -928,6 +932,8 @@ mime_part_write_to_output_stream_sync (CamelDataWrapper *dw,
 
                        temp_stream = camel_filter_output_stream_new (
                                filter_stream, filter);
+                       g_filter_output_stream_set_close_base_stream (
+                               G_FILTER_OUTPUT_STREAM (temp_stream), FALSE);
                        g_object_unref (filter);
 
                        g_object_unref (filter_stream);
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index f6f2ab4..a636dd0 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -8646,6 +8646,9 @@ camel_imapx_server_append_message (CamelIMAPXServer *is,
        filter = camel_mime_filter_canon_new (CAMEL_MIME_FILTER_CANON_CRLF);
        filter_stream = camel_filter_output_stream_new (output_stream, filter);
 
+       g_filter_output_stream_set_close_base_stream (
+               G_FILTER_OUTPUT_STREAM (filter_stream), FALSE);
+
        res = camel_data_wrapper_write_to_output_stream_sync (
                CAMEL_DATA_WRAPPER (message),
                filter_stream, cancellable, error);


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