X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-attachment-view.c;fp=src%2Fwidgets%2Fmodest-attachment-view.c;h=38a2146fb65cc36fd65cdedda4ceb8a53dbd3252;hp=a94f1a01131d78a78c7a8ccc9d12a7704476baf1;hb=bd40bdfd7bd5ae772566e0e05b5ff4e9126bdb9f;hpb=47ce1972da46c8ae2c8df7aba4141f75b688e219 diff --git a/src/widgets/modest-attachment-view.c b/src/widgets/modest-attachment-view.c index a94f1a0..38a2146 100644 --- a/src/widgets/modest-attachment-view.c +++ b/src/widgets/modest-attachment-view.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -128,17 +127,15 @@ get_mime_part_size_thread (gpointer thr_user_data) { ModestAttachmentView *view = (ModestAttachmentView *) thr_user_data; ModestAttachmentViewPrivate *priv = MODEST_ATTACHMENT_VIEW_GET_PRIVATE (view); - TnyStream *stream; gsize total = 0; gssize result = 0; - stream = modest_count_stream_new(); - result = tny_mime_part_decode_to_stream (priv->mime_part, stream, NULL); - total = modest_count_stream_get_count(MODEST_COUNT_STREAM (stream)); + result = tny_mime_part_decode_to_stream (priv->mime_part, priv->get_size_stream, NULL); + total = modest_count_stream_get_count(MODEST_COUNT_STREAM (priv->get_size_stream)); if (total == 0) { - modest_count_stream_reset_count(MODEST_COUNT_STREAM (stream)); - result = tny_mime_part_write_to_stream (priv->mime_part, stream, NULL); - total = modest_count_stream_get_count(MODEST_COUNT_STREAM (stream)); + modest_count_stream_reset_count(MODEST_COUNT_STREAM (priv->get_size_stream)); + result = tny_mime_part_write_to_stream (priv->mime_part, priv->get_size_stream, NULL); + total = modest_count_stream_get_count(MODEST_COUNT_STREAM (priv->get_size_stream)); } /* if there was an error, don't set the size (this is pretty uncommon) */ @@ -148,8 +145,6 @@ get_mime_part_size_thread (gpointer thr_user_data) priv->size = (guint64)total; g_idle_add (idle_get_mime_part_size_cb, g_object_ref (view)); } - - g_object_unref (stream); g_object_unref (view); return NULL; @@ -296,8 +291,9 @@ modest_attachment_view_set_part_default (TnyMimePartView *self, TnyMimePart *mim gtk_label_set_text (GTK_LABEL (priv->size_view), ""); if (show_size && priv->detect_size) { - tny_camel_mem_stream_get_type (); g_object_ref (self); + if (!priv->get_size_stream) + priv->get_size_stream = modest_count_stream_new (); g_thread_create (get_mime_part_size_thread, self, FALSE, NULL); } @@ -321,10 +317,8 @@ modest_attachment_view_clear_default (TnyMimePartView *self) priv->mime_part = NULL; } - if (priv->get_size_stream != NULL) { - g_object_unref (priv->get_size_stream); - priv->get_size_stream = NULL; - } + if (priv->get_size_stream) + modest_count_stream_reset_count(MODEST_COUNT_STREAM (priv->get_size_stream)); priv->size = 0;