aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-data-wrapper.c
diff options
context:
space:
mode:
Diffstat (limited to 'camel/camel-data-wrapper.c')
-rw-r--r--camel/camel-data-wrapper.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/camel/camel-data-wrapper.c b/camel/camel-data-wrapper.c
index cd4fcce7de..6f6aac6a16 100644
--- a/camel/camel-data-wrapper.c
+++ b/camel/camel-data-wrapper.c
@@ -145,9 +145,14 @@ static void
my_set_input_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
g_assert (data_wrapper);
+
+ if (data_wrapper->input_stream)
+ gtk_object_unref (GTK_OBJECT (data_wrapper->input_stream));
+
data_wrapper->input_stream = stream;
+
if (!data_wrapper->output_stream && stream)
- data_wrapper->output_stream = stream;
+ my_set_output_stream (data_wrapper, stream);
if (stream)
gtk_object_ref (GTK_OBJECT (stream));
@@ -186,6 +191,10 @@ static void
my_set_output_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
{
g_assert (data_wrapper);
+
+ if (data_wrapper->output_stream)
+ gtk_object_unref (GTK_OBJECT (data_wrapper->output_stream));
+
data_wrapper->output_stream = stream;
if (stream)
gtk_object_ref (GTK_OBJECT (stream));
@@ -251,6 +260,11 @@ my_write_to_stream (CamelDataWrapper *data_wrapper, CamelStream *stream)
output_stream = camel_data_wrapper_get_output_stream (data_wrapper);
+ if (!output_stream)
+ return;
+
+ camel_stream_reset (output_stream);
+
while (!camel_stream_eos (output_stream)) {
nb_read = camel_stream_read (output_stream, tmp_buf, 4096);
nb_written = 0;