changeset 4638:b58c08b7cbe4

[gaim-migrate @ 4946] This should fix the "Closing a window with chats causes gaim to go kab00m" bug. Please test it. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 02 Mar 2003 23:02:25 +0000
parents bf89c7598989
children 2c9f1ac20b36
files src/conversation.c
diffstat 1 files changed, 33 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/conversation.c	Sun Mar 02 22:55:26 2003 +0000
+++ b/src/conversation.c	Sun Mar 02 23:02:25 2003 +0000
@@ -40,7 +40,6 @@
 {
 	char *name;
 	gaim_conv_placement_fnc fnc;
-
 };
 
 #define SEND_TYPED_TIMEOUT 5000
@@ -464,28 +463,40 @@
 
 	ops = gaim_window_get_ui_ops(win);
 
-	for (node = g_list_first(gaim_window_get_conversations(win));
-		 node != NULL;
-		 node = g_list_next(node))
+	/*
+	 * If there are any conversations in this, destroy them all. The last
+	 * conversation will call gaim_window_destroy(), but this time, this
+	 * check will fail and the window will actually be destroyed.
+	 *
+	 * This is needed because chats may not close right away. They may
+	 * wait for notification first. When they get that, the window is
+	 * already destroyed, and gaim either crashes or spits out gtk warnings.
+	 * The problem is fixed with this check.
+	 */
+	if (gaim_window_get_conversation_count(win) > 0) {
+
+		for (node = g_list_first(gaim_window_get_conversations(win));
+			 node != NULL;
+			 node = g_list_next(node))
+		{
+			struct gaim_conversation *conv;
+
+			conv = (struct gaim_conversation *)node->data;
+
+			gaim_conversation_destroy(conv);
+		}
+	}
+	else
 	{
-		struct gaim_conversation *conv;
-		
-		conv = (struct gaim_conversation *)node->data;
-
-		conv->window = NULL;
-		gaim_conversation_destroy(conv);
-
-		node->data = NULL;
+		if (ops != NULL && ops->destroy_window != NULL)
+			ops->destroy_window(win);
+
+		g_list_free(gaim_window_get_conversations(win));
+
+		windows = g_list_remove(windows, win);
+
+		g_free(win);
 	}
-
-	if (ops != NULL && ops->destroy_window != NULL)
-		ops->destroy_window(win);
-
-	g_list_free(gaim_window_get_conversations(win));
-
-	windows = g_list_remove(windows, win);
-
-	g_free(win);
 }
 
 void
@@ -959,6 +970,7 @@
 		 *
 		 *   -- ChipX86
 		 */
+
 		if (gc && g_slist_find(gc->buddy_chats, conv) != NULL) {
 			serv_chat_leave(gc, gaim_chat_get_id(GAIM_CHAT(conv)));