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.
This commit is contained in:
Patrick Griffis 2016-07-24 21:14:11 -04:00
parent ac986bb3a4
commit aabcf6f9f4
1 changed files with 7 additions and 12 deletions

View File

@ -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);