From a8baf4a2a2211a0df19e321780678236aaffe477 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 5 May 2011 18:09:59 -0400 Subject: [PATCH] Change 'debugexit' to quit main loop rather than exit(), add cleanup A new envrionment variable GNOME_SHELL_ENABLE_CLEANUP is added which causes us to attempt freeing global data. The reason this isn't enabled by default is that it's a waste of time at best, and at worst in corner cases could cause crashes which would fill up crash databases. Better to leave it as a developer-only tool. Start stubbing out some cleanup in ShellGlobal. https://bugzilla.gnome.org/show_bug.cgi?id=649517 --- js/ui/runDialog.js | 2 +- src/main.c | 11 ++++++++++- src/shell-global.c | 19 +++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/js/ui/runDialog.js b/js/ui/runDialog.js index 3114bd824..192a93ae7 100644 --- a/js/ui/runDialog.js +++ b/js/ui/runDialog.js @@ -189,7 +189,7 @@ __proto__: ModalDialog.ModalDialog.prototype, }), 'debugexit': Lang.bind(this, function() { - Meta.exit(Meta.ExitCode.ERROR); + Meta.quit(Meta.ExitCode.ERROR); }), // rt is short for "reload theme" diff --git a/src/main.c b/src/main.c index c9c9d6e12..0e7718719 100644 --- a/src/main.c +++ b/src/main.c @@ -453,6 +453,7 @@ main (int argc, char **argv) { GOptionContext *ctx; GError *error = NULL; + int ecode; g_type_init (); @@ -507,5 +508,13 @@ main (int argc, char **argv) /* Initialize the global object */ shell_global_get (); - return meta_run (); + ecode = meta_run (); + + if (g_getenv ("GNOME_SHELL_ENABLE_CLEANUP")) + { + g_printerr ("Doing final cleanup...\n"); + g_object_unref (shell_global_get ()); + } + + return ecode; } diff --git a/src/shell-global.c b/src/shell-global.c index 9cb2c5078..e18dbc998 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -34,6 +34,8 @@ #include "shell-wm.h" #include "st.h" +static ShellGlobal *the_object = NULL; + static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data); struct _ShellGlobal { @@ -254,6 +256,20 @@ shell_global_init (ShellGlobal *global) g_strfreev (search_path); } +static void +shell_global_finalize (GObject *object) +{ + ShellGlobal *global = SHELL_GLOBAL (object); + + g_object_unref (global->js_context); + gtk_widget_destroy (GTK_WIDGET (global->grab_notifier)); + g_object_unref (global->settings); + + the_object = NULL; + + G_OBJECT_CLASS(shell_global_parent_class)->finalize (object); +} + static void shell_global_class_init (ShellGlobalClass *klass) { @@ -261,6 +277,7 @@ shell_global_class_init (ShellGlobalClass *klass) gobject_class->get_property = shell_global_get_property; gobject_class->set_property = shell_global_set_property; + gobject_class->finalize = shell_global_finalize; /* Emitted from gnome-shell-plugin.c during event handling */ shell_global_signals[XDND_POSITION_CHANGED] = @@ -424,8 +441,6 @@ shell_global_class_init (ShellGlobalClass *klass) ShellGlobal * shell_global_get (void) { - static ShellGlobal *the_object = NULL; - if (!the_object) the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);