diff finch/libgnt/gntwm.c @ 18716:0873698f8cce

This fixes a few weird crashes in pygnt.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 29 Jul 2007 15:58:08 +0000
parents ab58b55f38b0
children fad7efbb98a6
line wrap: on
line diff
--- 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;