# HG changeset patch # User Christian Hammond # Date 1046646145 0 # Node ID b58c08b7cbe495136a46d826e810265010531cc8 # Parent bf89c7598989827ab9382b68d7636d43c02ca68b [gaim-migrate @ 4946] This should fix the "Closing a window with chats causes gaim to go kab00m" bug. Please test it. committer: Tailor Script diff -r bf89c7598989 -r b58c08b7cbe4 src/conversation.c --- 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)));