From bd40bdfd7bd5ae772566e0e05b5ff4e9126bdb9f Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Thu, 31 Jan 2008 13:03:13 +0000 Subject: [PATCH] * Fixes NB#80090, fixed a crash when viewing messages with attachments pmo-trunk-r4119 --- src/modest-count-stream.c | 8 +++++--- src/widgets/modest-attachment-view.c | 24 +++++++++--------------- src/widgets/modest-folder-view.c | 2 -- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/modest-count-stream.c b/src/modest-count-stream.c index 4ad1287..d0aba97 100644 --- a/src/modest-count-stream.c +++ b/src/modest-count-stream.c @@ -147,8 +147,10 @@ modest_count_stream_instance_init (GTypeInstance *instance, gpointer g_class) } static void -tny_stream_init (TnyStreamIface *klass) +tny_stream_init (gpointer g_iface, gpointer iface_data) { + TnyStreamIface *klass = (TnyStreamIface *) g_iface; + klass->read = modest_count_stream_read; klass->write = modest_count_stream_write; klass->flush = modest_count_stream_flush; @@ -198,8 +200,8 @@ modest_count_stream_get_type (void) }; type = g_type_register_static (G_TYPE_OBJECT, - "ModestCountStream", - &info, 0); + "ModestCountStream", + &info, 0); /* TODO? : FIX THIS (ADD _TYPE): */ g_type_add_interface_static (type, TNY_TYPE_STREAM, 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; diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index e22b93e..68ed0bb 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -1070,8 +1070,6 @@ tny_account_store_view_init (gpointer g, gpointer iface_data) TnyAccountStoreViewIface *klass = (TnyAccountStoreViewIface *)g; klass->set_account_store = modest_folder_view_set_account_store; - - return; } static void -- 1.7.9.5