# HG changeset patch # User Sadrul Habib Chowdhury # Date 1185724688 0 # Node ID 0873698f8cce2d08dbf7b09c4efc6def5f660f0e # Parent 64a7b13d3b8ddca19da995c60218e7ea4b47b3a9 This fixes a few weird crashes in pygnt. diff -r 64a7b13d3b8d -r 0873698f8cce finch/libgnt/gntmain.c --- a/finch/libgnt/gntmain.c Sun Jul 29 10:48:45 2007 +0000 +++ b/finch/libgnt/gntmain.c Sun Jul 29 15:58:08 2007 +0000 @@ -517,7 +517,8 @@ void gnt_screen_release(GntWidget *widget) { - gnt_wm_window_close(wm, widget); + if (wm) + gnt_wm_window_close(wm, widget); } void gnt_screen_update(GntWidget *widget) @@ -564,7 +565,9 @@ void gnt_quit() { - g_hash_table_destroy(wm->nodes); /* XXX: */ + g_object_unref(G_OBJECT(wm)); + wm = NULL; + update_panels(); doupdate(); gnt_uninit_colors(); diff -r 64a7b13d3b8d -r 0873698f8cce finch/libgnt/gntwm.c --- a/finch/libgnt/gntwm.c Sun Jul 29 10:48:45 2007 +0000 +++ b/finch/libgnt/gntwm.c Sun Jul 29 15:58:08 2007 +0000 @@ -1137,9 +1137,37 @@ } static void +accumulate_windows(gpointer window, gpointer node, gpointer p) +{ + GList *list = *(GList**)p; + list = g_list_prepend(list, window); + *(GList**)p = list; +} + +static void +gnt_wm_destroy(GObject *obj) +{ + GntWM *wm = GNT_WM(obj); + GList *list = NULL; + g_hash_table_foreach(wm->nodes, accumulate_windows, &list); + g_list_foreach(list, gnt_widget_destroy, NULL); + g_list_free(list); + g_hash_table_destroy(wm->nodes); + wm->nodes = NULL; + + while (wm->workspaces) { + g_object_unref(wm->workspaces->data); + wm->workspaces = g_list_delete_link(wm->workspaces, wm->workspaces); + } +} + +static void gnt_wm_class_init(GntWMClass *klass) { int i; + GObjectClass *gclass = G_OBJECT_CLASS(klass); + + gclass->dispose = gnt_wm_destroy; klass->new_window = gnt_wm_new_window_real; klass->decorate_window = NULL;