[evolution/wip/webkit2] Free EMailFormatter/Parser extension caches on application exit



commit 3e3bf78c3c720a3025561c9bfe3d6062146585b7
Author: Milan Crha <mcrha redhat com>
Date:   Wed Nov 18 18:14:19 2015 +0100

    Free EMailFormatter/Parser extension caches on application exit

 em-format/e-mail-formatter-print.c |    2 --
 em-format/e-mail-formatter-quote.c |    2 --
 em-format/e-mail-formatter.c       |   25 +++++++++++++++++--------
 em-format/e-mail-parser.c          |   24 ++++++++++++++++--------
 mail/e-mail-paned-view.c           |    2 +-
 5 files changed, 34 insertions(+), 21 deletions(-)
---
diff --git a/em-format/e-mail-formatter-print.c b/em-format/e-mail-formatter-print.c
index 033ef3c..3806ca9 100644
--- a/em-format/e-mail-formatter-print.c
+++ b/em-format/e-mail-formatter-print.c
@@ -31,8 +31,6 @@
 /* internal formatter extensions */
 GType e_mail_formatter_print_headers_get_type (void);
 
-void e_mail_formatter_print_internal_extensions_load (EMailExtensionRegistry *ereg);
-
 static gpointer e_mail_formatter_print_parent_class = 0;
 
 static void
diff --git a/em-format/e-mail-formatter-quote.c b/em-format/e-mail-formatter-quote.c
index 99b31fe..adbe223 100644
--- a/em-format/e-mail-formatter-quote.c
+++ b/em-format/e-mail-formatter-quote.c
@@ -45,8 +45,6 @@ GType e_mail_formatter_quote_text_enriched_get_type (void);
 GType e_mail_formatter_quote_text_html_get_type (void);
 GType e_mail_formatter_quote_text_plain_get_type (void);
 
-void e_mail_formatter_quote_internal_extensions_load (EMailExtensionRegistry *ereg);
-
 static gpointer e_mail_formatter_quote_parent_class = 0;
 
 static void
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index d605524..8c793de 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -23,6 +23,7 @@
 #include <libebackend/libebackend.h>
 
 #include <e-util/e-util.h>
+#include <shell/e-shell.h>
 
 #include "e-mail-formatter-enumtypes.h"
 #include "e-mail-formatter-extension.h"
@@ -75,8 +76,6 @@ GType e_mail_formatter_text_enriched_get_type (void);
 GType e_mail_formatter_text_html_get_type (void);
 GType e_mail_formatter_text_plain_get_type (void);
 
-void e_mail_formatter_internal_extensions_load (EMailExtensionRegistry *ereg);
-
 static gpointer e_mail_formatter_parent_class = 0;
 
 enum {
@@ -143,6 +142,17 @@ mail_formatter_free_context (EMailFormatterContext *context)
 }
 
 static void
+shell_gone_cb (gpointer user_data,
+              GObject *gone_extension_registry)
+{
+       EMailFormatterClass *class = user_data;
+
+       g_return_if_fail (class != NULL);
+
+       g_clear_object (&class->extension_registry);
+}
+
+static void
 e_mail_formatter_set_property (GObject *object,
                                guint property_id,
                                const GValue *value,
@@ -547,6 +557,8 @@ mail_formatter_update_style (EMailFormatter *formatter,
 static void
 e_mail_formatter_base_init (EMailFormatterClass *class)
 {
+       EShell *shell;
+
        /* Register internal extensions. */
        g_type_ensure (e_mail_formatter_attachment_get_type ());
        g_type_ensure (e_mail_formatter_attachment_bar_get_type ());
@@ -577,12 +589,9 @@ e_mail_formatter_base_init (EMailFormatterClass *class)
                CAMEL_MIME_FILTER_TOHTML_CONVERT_SPACES |
                CAMEL_MIME_FILTER_TOHTML_CONVERT_ADDRESSES |
                CAMEL_MIME_FILTER_TOHTML_MARK_CITATION;
-}
 
-static void
-e_mail_formatter_base_finalize (EMailFormatterClass *class)
-{
-       g_object_unref (class->extension_registry);
+       shell = e_shell_get_default ();
+       g_object_weak_ref (G_OBJECT (shell), shell_gone_cb, class);
 }
 
 static void
@@ -803,7 +812,7 @@ e_mail_formatter_get_type (void)
                const GTypeInfo type_info = {
                        sizeof (EMailFormatterClass),
                        (GBaseInitFunc) e_mail_formatter_base_init,
-                       (GBaseFinalizeFunc) e_mail_formatter_base_finalize,
+                       (GBaseFinalizeFunc) NULL,
                        (GClassInitFunc) e_mail_formatter_class_init,
                        (GClassFinalizeFunc) NULL,
                        NULL,   /* class_data */
diff --git a/em-format/e-mail-parser.c b/em-format/e-mail-parser.c
index c686a9c..c78cb70 100644
--- a/em-format/e-mail-parser.c
+++ b/em-format/e-mail-parser.c
@@ -79,8 +79,6 @@ GType e_mail_parser_text_plain_get_type (void);
 GType e_mail_parser_application_smime_get_type (void);
 #endif
 
-void e_mail_parser_internal_extensions_load (EMailExtensionRegistry *ereg);
-
 static gpointer parent_class;
 
 static void
@@ -147,6 +145,17 @@ mail_parser_run (EMailParser *parser,
 }
 
 static void
+shell_gone_cb (gpointer user_data,
+              GObject *gone_extension_registry)
+{
+       EMailParserClass *class = user_data;
+
+       g_return_if_fail (class != NULL);
+
+       g_clear_object (&class->extension_registry);
+}
+
+static void
 mail_parser_set_session (EMailParser *parser,
                          CamelSession *session)
 {
@@ -208,6 +217,8 @@ e_mail_parser_finalize (GObject *object)
 static void
 e_mail_parser_base_init (EMailParserClass *class)
 {
+       EShell *shell;
+
        /* Register internal extensions. */
        g_type_ensure (e_mail_parser_application_mbox_get_type ());
        g_type_ensure (e_mail_parser_attachment_bar_get_type ());
@@ -242,12 +253,9 @@ e_mail_parser_base_init (EMailParserClass *class)
        e_mail_parser_extension_registry_load (class->extension_registry);
 
        e_extensible_load_extensions (E_EXTENSIBLE (class->extension_registry));
-}
 
-static void
-e_mail_parser_base_finalize (EMailParserClass *class)
-{
-       g_object_unref (class->extension_registry);
+       shell = e_shell_get_default ();
+       g_object_weak_ref (G_OBJECT (shell), shell_gone_cb, class);
 }
 
 static void
@@ -292,7 +300,7 @@ e_mail_parser_get_type (void)
                static const GTypeInfo type_info = {
                        sizeof (EMailParserClass),
                        (GBaseInitFunc) e_mail_parser_base_init,
-                       (GBaseFinalizeFunc) e_mail_parser_base_finalize,
+                       (GBaseFinalizeFunc) NULL,
                        (GClassInitFunc) e_mail_parser_class_init,
                        (GClassFinalizeFunc) NULL,
                        NULL,  /* class_data */
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 902dbe1..6536643 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -714,8 +714,8 @@ mail_paned_view_constructed (GObject *object)
        gtk_scrolled_window_set_policy (
                GTK_SCROLLED_WINDOW (widget),
                GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
-       priv->scrolled_window = g_object_ref (widget);
        gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
+       priv->scrolled_window = g_object_ref (widget);
        gtk_widget_show (widget);
 
        container = widget;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]