[evolution] calendar_config_init: Avoid runtime warning when called out of Evolution



commit 467ac31af341cff6868f8cdce189535fd5bdd762
Author: Milan Crha <mcrha redhat com>
Date:   Wed Sep 11 18:51:24 2019 +0200

    calendar_config_init: Avoid runtime warning when called out of Evolution
    
    The idea of freeing global memory on an EShell dispose works only if
    the function is called in Evolution itself, where such EShell instance
    exists, but it fails everywhere else, like in tests and also on the
    evolution-data-server factory side, when used by evolution-ews.
    The change doesn't really fix this, it either is able to free
    the global memory as before, or the memory is leaked.

 src/calendar/gui/calendar-config.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/calendar/gui/calendar-config.c b/src/calendar/gui/calendar-config.c
index c21a915d2a..1f1658aac9 100644
--- a/src/calendar/gui/calendar-config.c
+++ b/src/calendar/gui/calendar-config.c
@@ -47,16 +47,22 @@ do_cleanup (void)
 static void
 calendar_config_init (void)
 {
+       EShell *shell;
+
        if (config)
                return;
 
        config = e_util_ref_settings ("org.gnome.evolution.calendar");
 
-       /* will be freed together with EShell */
-       g_object_set_data_full (
-               G_OBJECT (e_shell_get_default ()),
-               "calendar-config-config-cleanup", (gpointer) "1",
-               (GDestroyNotify) do_cleanup);
+       shell = e_shell_get_default ();
+
+       if (shell) {
+               /* will be freed together with EShell, or will leak */
+               g_object_set_data_full (
+                       G_OBJECT (shell),
+                       "calendar-config-config-cleanup", (gpointer) "1",
+                       (GDestroyNotify) do_cleanup);
+       }
 }
 
 void


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