Revise the EShell ref-leak check to not upset Valgrind.
This commit is contained in:
@ -91,8 +91,8 @@ static GDebugKey debug_keys[] = {
|
||||
{ "settings", DEBUG_KEY_SETTINGS }
|
||||
};
|
||||
|
||||
EShell *default_shell = NULL;
|
||||
static gpointer parent_class;
|
||||
static gpointer default_shell;
|
||||
static guint signals[LAST_SIGNAL];
|
||||
|
||||
#if defined(NM_SUPPORT) && NM_SUPPORT
|
||||
@ -624,8 +624,10 @@ static void
|
||||
shell_constructed (GObject *object)
|
||||
{
|
||||
/* The first EShell instance is the default. */
|
||||
if (default_shell == NULL)
|
||||
default_shell = g_object_ref (object);
|
||||
if (default_shell == NULL) {
|
||||
default_shell = object;
|
||||
g_object_add_weak_pointer (object, &default_shell);
|
||||
}
|
||||
|
||||
/* UniqueApp will have by this point determined whether we're
|
||||
* the only Evolution process running. If so, proceed normally.
|
||||
@ -1148,9 +1150,6 @@ e_shell_get_type (void)
|
||||
EShell *
|
||||
e_shell_get_default (void)
|
||||
{
|
||||
/* Emit a warning if we call this too early. */
|
||||
g_return_val_if_fail (default_shell != NULL, NULL);
|
||||
|
||||
return default_shell;
|
||||
}
|
||||
|
||||
|
||||
24
shell/main.c
24
shell/main.c
@ -93,9 +93,6 @@ static gchar *requested_view = NULL;
|
||||
static gchar *evolution_debug_log = NULL;
|
||||
static gchar **remaining_args;
|
||||
|
||||
/* Defined in <e-shell.h> */
|
||||
extern EShell *default_shell;
|
||||
|
||||
static void
|
||||
categories_icon_theme_hack (void)
|
||||
{
|
||||
@ -397,7 +394,7 @@ shell_force_shutdown (void)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static void
|
||||
static EShell *
|
||||
create_default_shell (void)
|
||||
{
|
||||
EShell *shell;
|
||||
@ -441,11 +438,9 @@ create_default_shell (void)
|
||||
|
||||
g_object_unref (client);
|
||||
|
||||
/* EShell keeps its own reference to the first instance for use
|
||||
* in e_shell_get_default(), so it's safe to unreference here. */
|
||||
g_object_unref (shell);
|
||||
|
||||
g_idle_add ((GSourceFunc) idle_cb, remaining_args);
|
||||
|
||||
return shell;
|
||||
}
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
@ -455,6 +450,7 @@ extern void link_shutdown (void);
|
||||
gint
|
||||
main (gint argc, gchar **argv)
|
||||
{
|
||||
EShell *shell;
|
||||
GtkIconTheme *icon_theme;
|
||||
GConfClient *client;
|
||||
#ifdef DEVELOPMENT
|
||||
@ -580,7 +576,7 @@ main (gint argc, gchar **argv)
|
||||
|
||||
g_object_unref (client);
|
||||
|
||||
create_default_shell ();
|
||||
shell = create_default_shell ();
|
||||
|
||||
if (!disable_eplugin) {
|
||||
/* Register built-in plugin hook types. */
|
||||
@ -597,14 +593,16 @@ main (gint argc, gchar **argv)
|
||||
|
||||
/* Attempt migration -after- loading all modules and plugins,
|
||||
* as both shell backends and certain plugins hook into this. */
|
||||
e_shell_migrate_attempt (default_shell);
|
||||
e_shell_migrate_attempt (shell);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
/* Drop what should be the last reference to the shell.
|
||||
* Emit a warning if references are leaking somewhere. */
|
||||
g_object_unref (default_shell);
|
||||
if (E_IS_SHELL (default_shell))
|
||||
* That will cause e_shell_get_default() to henceforth
|
||||
* return NULL. Use that to check for reference leaks. */
|
||||
g_object_unref (shell);
|
||||
|
||||
if (e_shell_get_default () != NULL)
|
||||
g_warning ("Shell not finalized on exit");
|
||||
|
||||
gtk_accel_map_save (e_get_accels_filename ());
|
||||
|
||||
Reference in New Issue
Block a user