Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 24310:4acda11bf672
Don't try to remove GtkIMHtmlSmileys from smiley trees if the GtkIMHtml
that the smiley refers to doesn't exist anymore.
Yes, I know this is a bit hacky, but I couldn't find another obvious way to do
it without adding stuff in gtksmiley.c...
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 03 Nov 2008 20:36:38 +0000 |
parents | 8282911d5e17 |
children | 9ea84135db24 |
comparison
equal
deleted
inserted
replaced
24309:260c6f4e6563 | 24310:4acda11bf672 |
---|---|
2043 return len; | 2043 return len; |
2044 | 2044 |
2045 return 0; | 2045 return 0; |
2046 } | 2046 } |
2047 | 2047 |
2048 /* a hack-around to prevent trying to doing gtk_smiley_tree_remove on a | |
2049 GtkIMHtml that no longer lives... I know this is ugly, but I couldn't find | |
2050 a better way to handle it for now, since there lives a list GtkIMHtmlSmileys | |
2051 in gtksmiley.c and those can end up having dangling imhtml pointers */ | |
2052 static gboolean | |
2053 gtk_imhtml_is_alive(const GtkIMHtml *imhtml) | |
2054 { | |
2055 GList *convs; | |
2056 | |
2057 for (convs = purple_get_conversations() ; convs != NULL ; | |
2058 convs = g_list_next(convs)) { | |
2059 PurpleConversation *conv = (PurpleConversation *) convs->data; | |
2060 | |
2061 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) { | |
2062 if (GTK_IMHTML(PIDGIN_CONVERSATION(conv)->imhtml) == imhtml | |
2063 || GTK_IMHTML(PIDGIN_CONVERSATION(conv)->entry) == imhtml) { | |
2064 return TRUE; | |
2065 } | |
2066 } | |
2067 } | |
2068 return FALSE; | |
2069 } | |
2070 | |
2048 static void | 2071 static void |
2049 gtk_imhtml_disassociate_smiley_foreach(gpointer key, gpointer value, | 2072 gtk_imhtml_disassociate_smiley_foreach(gpointer key, gpointer value, |
2050 gpointer user_data) | 2073 gpointer user_data) |
2051 { | 2074 { |
2052 GtkSmileyTree *tree = (GtkSmileyTree *) value; | 2075 GtkSmileyTree *tree = (GtkSmileyTree *) value; |
2055 } | 2078 } |
2056 | 2079 |
2057 static void | 2080 static void |
2058 gtk_imhtml_disassociate_smiley(GtkIMHtmlSmiley *smiley) | 2081 gtk_imhtml_disassociate_smiley(GtkIMHtmlSmiley *smiley) |
2059 { | 2082 { |
2060 if (smiley->imhtml) { | 2083 if (smiley->imhtml && gtk_imhtml_is_alive(smiley->imhtml)) { |
2061 gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); | 2084 gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
2062 g_hash_table_foreach(smiley->imhtml->smiley_data, | 2085 g_hash_table_foreach(smiley->imhtml->smiley_data, |
2063 gtk_imhtml_disassociate_smiley_foreach, smiley); | 2086 gtk_imhtml_disassociate_smiley_foreach, smiley); |
2087 smiley->imhtml = NULL; | |
2064 } | 2088 } |
2065 } | 2089 } |
2066 | 2090 |
2067 void | 2091 void |
2068 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, | 2092 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |