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
This commit is contained in:
Colin Walters 2011-05-05 18:09:59 -04:00
parent bfd344cdec
commit a8baf4a2a2
3 changed files with 28 additions and 4 deletions

View File

@ -189,7 +189,7 @@ __proto__: ModalDialog.ModalDialog.prototype,
}), }),
'debugexit': Lang.bind(this, function() { 'debugexit': Lang.bind(this, function() {
Meta.exit(Meta.ExitCode.ERROR); Meta.quit(Meta.ExitCode.ERROR);
}), }),
// rt is short for "reload theme" // rt is short for "reload theme"

View File

@ -453,6 +453,7 @@ main (int argc, char **argv)
{ {
GOptionContext *ctx; GOptionContext *ctx;
GError *error = NULL; GError *error = NULL;
int ecode;
g_type_init (); g_type_init ();
@ -507,5 +508,13 @@ main (int argc, char **argv)
/* Initialize the global object */ /* Initialize the global object */
shell_global_get (); 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;
} }

View File

@ -34,6 +34,8 @@
#include "shell-wm.h" #include "shell-wm.h"
#include "st.h" #include "st.h"
static ShellGlobal *the_object = NULL;
static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data); static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data);
struct _ShellGlobal { struct _ShellGlobal {
@ -254,6 +256,20 @@ shell_global_init (ShellGlobal *global)
g_strfreev (search_path); 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 static void
shell_global_class_init (ShellGlobalClass *klass) 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->get_property = shell_global_get_property;
gobject_class->set_property = shell_global_set_property; gobject_class->set_property = shell_global_set_property;
gobject_class->finalize = shell_global_finalize;
/* Emitted from gnome-shell-plugin.c during event handling */ /* Emitted from gnome-shell-plugin.c during event handling */
shell_global_signals[XDND_POSITION_CHANGED] = shell_global_signals[XDND_POSITION_CHANGED] =
@ -424,8 +441,6 @@ shell_global_class_init (ShellGlobalClass *klass)
ShellGlobal * ShellGlobal *
shell_global_get (void) shell_global_get (void)
{ {
static ShellGlobal *the_object = NULL;
if (!the_object) if (!the_object)
the_object = g_object_new (SHELL_TYPE_GLOBAL, 0); the_object = g_object_new (SHELL_TYPE_GLOBAL, 0);