[evolution/webkit: 38/102] Don't store formatters directly in SoupSession's data
- From: Dan VrÃtil <dvratil src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit: 38/102] Don't store formatters directly in SoupSession's data
- Date: Fri, 6 Jan 2012 09:28:17 +0000 (UTC)
commit 20b69b6618cfa4bf45052fc953b20422b49e25bd
Author: Dan VrÃtil <dvratil redhat com>
Date: Thu Oct 6 16:49:01 2011 +0200
Don't store formatters directly in SoupSession's data
Formatters are now stored in GHashTable which is stored in SoupSession
GObject data. This way all formatters can be safely iterated without
need to check if there are another data stored in the SoupSession.
mail/e-mail-reader.c | 16 ++++++++++++----
mail/e-mail-request.c | 7 +++++--
2 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index c5ad7aa..3e16eed 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2558,6 +2558,7 @@ mail_reader_message_loaded_cb (CamelFolder *folder,
GtkWidget *message_list;
const gchar *message_uid;
GError *error = NULL;
+ GHashTable *formatters;
reader = closure->reader;
message_uid = closure->message_uid;
@@ -2863,7 +2864,7 @@ mail_reader_message_loaded (EMailReader *reader,
GError *error = NULL;
gchar *mail_uri;
SoupSession *session;
- GHashTable *formattters;
+ GHashTable *formatters;
GCancellable *cancellable;
priv = E_MAIL_READER_GET_PRIVATE (reader);
@@ -2895,16 +2896,23 @@ mail_reader_message_loaded (EMailReader *reader,
mail_uri = em_format_build_mail_uri (folder, message_uid, NULL, NULL);
session = webkit_get_default_session ();
- if ((formatter = g_object_get_data (G_OBJECT (session), mail_uri)) == NULL) {
+ formatters = g_object_get_data (G_OBJECT (session), "formatters");
+ if (!formatters) {
+ formatters = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
+ g_object_set_data (G_OBJECT (session), "formatters", formatters);
+ }
+
+
+ if ((formatter = g_hash_table_lookup (formatters, mail_uri)) == NULL) {
formatter = em_format_html_display_new ();
EM_FORMAT (formatter)->message_uid = g_strdup (message_uid);
em_format_parse (EM_FORMAT (formatter), message, folder, NULL);
- g_object_set_data (G_OBJECT (session), mail_uri, formatter);
+ g_hash_table_insert (formatters, mail_uri, formatter);
}
e_mail_display_set_formatter (display, EM_FORMAT_HTML (formatter));
e_mail_display_load (display, mail_uri);
- g_free (mail_uri);
/* Reset the shell view icon. */
e_shell_event (shell, "mail-icon", (gpointer) "evolution-mail");
diff --git a/mail/e-mail-request.c b/mail/e-mail-request.c
index 052d43b..7c52c00 100644
--- a/mail/e-mail-request.c
+++ b/mail/e-mail-request.c
@@ -175,6 +175,7 @@ mail_request_send_async (SoupRequest *request,
d(printf("received request for %s\n", soup_uri_to_string (uri, FALSE)));
if (g_strcmp0 (uri->scheme, "mail") == 0) {
+ GHashTable *formatters;
gchar *uri_str;
if (!uri->query) {
@@ -182,9 +183,11 @@ mail_request_send_async (SoupRequest *request,
g_return_if_fail (uri->query);
}
- uri_str = g_strdup_printf ("%s://%s%s", uri->scheme, uri->host, uri->path);
+ formatters = g_object_get_data (G_OBJECT (session), "formatters");
+ g_return_if_fail (formatters != NULL);
- emr->priv->efh = g_object_get_data (G_OBJECT (session), uri_str);
+ uri_str = g_strdup_printf ("%s://%s%s", uri->scheme, uri->host, uri->path);
+ emr->priv->efh = g_hash_table_lookup (formatters, uri_str);
g_free (uri_str);
g_return_if_fail (emr->priv->efh);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]