From 91af6345792cb2824f714df5249d5fc4c035f783 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 12 Aug 2002 19:36:08 +0000 Subject: Don't call new_from_mime_part() since that function now does some copying 2002-08-12 Jeffrey Stedfast * e-msg-composer-attachment.c (e_msg_composer_attachment_new): Don't call new_from_mime_part() since that function now does some copying of the mime part rather than simply reffing it. (e_msg_composer_attachment_new_from_mime_part): Make a copy of the MIME part so that if the message that this part belongs to gets deleted from the the remote store, the composer will still have a copy of it. Fixes bug #20308. svn path=/trunk/; revision=17760 --- composer/ChangeLog | 10 ++++++++++ composer/e-msg-composer-attachment.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) (limited to 'composer') diff --git a/composer/ChangeLog b/composer/ChangeLog index 33761d7e2e..89f7470b67 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,13 @@ +2002-08-12 Jeffrey Stedfast + + * e-msg-composer-attachment.c (e_msg_composer_attachment_new): + Don't call new_from_mime_part() since that function now does some + copying of the mime part rather than simply reffing it. + (e_msg_composer_attachment_new_from_mime_part): Make a copy of the + MIME part so that if the message that this part belongs to gets + deleted from the the remote store, the composer will still have a + copy of it. Fixes bug #20308. + 2002-07-31 Jeffrey Stedfast * e-msg-composer.c (e_msg_composer_new_with_message): Parse the diff --git a/composer/e-msg-composer-attachment.c b/composer/e-msg-composer-attachment.c index 7036461bbf..e0c2bd1f0f 100644 --- a/composer/e-msg-composer-attachment.c +++ b/composer/e-msg-composer-attachment.c @@ -216,9 +216,9 @@ e_msg_composer_attachment_new (const char *file_name, g_free (content_id); #endif - new = e_msg_composer_attachment_new_from_mime_part (part); - camel_object_unref (CAMEL_OBJECT (part)); - + new = gtk_type_new (e_msg_composer_attachment_get_type ()); + new->editor_gui = NULL; + new->body = part; new->size = statbuf.st_size; new->guessed_type = TRUE; @@ -236,17 +236,34 @@ EMsgComposerAttachment * e_msg_composer_attachment_new_from_mime_part (CamelMimePart *part) { EMsgComposerAttachment *new; - + CamelMimePart *mime_part; + CamelStream *stream; + g_return_val_if_fail (CAMEL_IS_MIME_PART (part), NULL); - + + stream = camel_stream_mem_new (); + if (camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (part), stream) == -1) { + camel_object_unref (stream); + return NULL; + } + + camel_stream_reset (stream); + mime_part = camel_mime_part_new (); + + if (camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (mime_part), stream) == -1) { + camel_object_unref (mime_part); + camel_object_unref (stream); + return NULL; + } + + camel_object_unref (stream); + new = gtk_type_new (e_msg_composer_attachment_get_type ()); - new->editor_gui = NULL; - new->body = part; - camel_object_ref (CAMEL_OBJECT (part)); + new->body = mime_part; new->guessed_type = FALSE; new->size = 0; - + return new; } -- cgit v1.2.3