changeset 19227:ae0f058f604e

Fix a crash regarding tooltips on the infopane. Steps to reproduce: Open a conversation, move the mouse and place it over the infopane, close the conversation window before the tooltip pops up.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 13 Aug 2007 06:22:08 +0000
parents a0d45fa8ecfc
children 03d81500766d
files pidgin/gtkconv.c
diffstat 1 files changed, 30 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkconv.c	Mon Aug 13 06:03:01 2007 +0000
+++ b/pidgin/gtkconv.c	Mon Aug 13 06:22:08 2007 +0000
@@ -4411,13 +4411,32 @@
 	gtk_container_add(GTK_CONTAINER(sw), list);
 }
 
-static int tooltip_timeout = 0;
+/* Stuff used to display tooltips on the infopane */
+static struct {
+	int timeout;
+	PidginConversation *gtkconv;   /* This is the Pidgin conversation that
+	                                  triggered the tooltip */
+} tooltip;
+
+static void
+reset_tooltip()
+{
+	if (tooltip.timeout != 0) {
+		g_source_remove(tooltip.timeout);
+		tooltip.timeout = 0;
+	}
+	tooltip.gtkconv = NULL;
+}
 
 static gboolean
 pidgin_conv_tooltip_timeout(PidginConversation *gtkconv)
 {
 	PurpleBlistNode *node = NULL;
-	PurpleConversation *conv = gtkconv->active_conv;
+	PurpleConversation *conv;
+
+	g_return_val_if_fail (tooltip.gtkconv == gtkconv, FALSE);
+
+	conv = gtkconv->active_conv;
 	if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
 		node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name));
 	} else {
@@ -4433,10 +4452,7 @@
 pidgin_conv_leave_cb (GtkWidget *w, GdkEventCrossing *e, PidginConversation *gtkconv)
 {
 	pidgin_blist_tooltip_destroy();
-	if (tooltip_timeout) {
-		g_source_remove(tooltip_timeout);
-		tooltip_timeout = 0;
-	}
+	reset_tooltip();
 }
 
 static gboolean 
@@ -4448,10 +4464,11 @@
 	if (delay == 0)
 		return FALSE;
 
-	if (tooltip_timeout != 0) 
-		g_source_remove(tooltip_timeout);
-
-	tooltip_timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv);
+	if (tooltip.timeout != 0) 
+		g_source_remove(tooltip.timeout);
+
+	tooltip.timeout = g_timeout_add(delay, (GSourceFunc)pidgin_conv_tooltip_timeout, gtkconv);
+	tooltip.gtkconv = gtkconv;
 	return FALSE;
 }
 
@@ -4985,6 +5002,9 @@
 	g_list_foreach(gtkconv->send_history, (GFunc)g_free, NULL);
 	g_list_free(gtkconv->send_history);
 
+	if (tooltip.gtkconv == gtkconv)
+		reset_tooltip();
+
 	g_free(gtkconv);
 }