From aabcf6f9f43c9b5346902cc013cae6d5bb7bc9ce Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Sun, 24 Jul 2016 21:14:11 -0400 Subject: Fix crashes when plugins modify UI during Close Context This probably doesn't catch them all but setting tab color and printing text at least do not crash in the common case. --- src/fe-gtk/maingui.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/fe-gtk') diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 9c283166..9a406703 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -173,7 +173,7 @@ void fe_set_tab_color (struct session *sess, int col) { struct session *server_sess = sess->server->server_session; - if (sess->gui->is_tab && (col == 0 || sess != current_tab)) + if (sess->res->tab && sess->gui->is_tab && (col == 0 || sess != current_tab)) { switch (col) { @@ -1010,12 +1010,6 @@ static void mg_topdestroy_cb (GtkWidget *win, session *sess) { /* printf("enter mg_topdestroy. sess %p was destroyed\n", sess);*/ - - /* kill the text buffer */ - gtk_xtext_buffer_free (sess->res->buffer); - /* kill the user list */ - g_object_unref (G_OBJECT (sess->res->user_model)); - session_free (sess); /* tell hexchat.c about it */ } @@ -1026,11 +1020,6 @@ mg_ircdestroy (session *sess) { GSList *list; - /* kill the text buffer */ - gtk_xtext_buffer_free (sess->res->buffer); - /* kill the user list */ - g_object_unref (G_OBJECT (sess->res->user_model)); - session_free (sess); /* tell hexchat.c about it */ if (mg_gui == NULL) @@ -1092,7 +1081,10 @@ mg_tab_close (session *sess) int i; if (chan_remove (sess->res->tab, FALSE)) + { + sess->res->tab = NULL; mg_ircdestroy (sess); + } else { for (i = 0, list = sess_list; list; list = list->next) @@ -3653,6 +3645,9 @@ fe_server_callback (server *serv) void fe_session_callback (session *sess) { + gtk_xtext_buffer_free (sess->res->buffer); + g_object_unref (G_OBJECT (sess->res->user_model)); + if (sess->res->banlist && sess->res->banlist->window) mg_close_gen (NULL, sess->res->banlist->window); -- cgit 1.4.1