changeset 4569:7f2de19d052d

[gaim-migrate @ 4850] Bug fix. Gaim would crash if using the IM convo window slider bars after plugin removal. committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Tue, 11 Feb 2003 00:58:28 +0000
parents ddc1f12b52d6
children 67a373071933
files plugins/win32/transparency/win2ktrans.c
diffstat 1 files changed, 43 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/win32/transparency/win2ktrans.c	Mon Feb 10 20:44:54 2003 +0000
+++ b/plugins/win32/transparency/win2ktrans.c	Tue Feb 11 00:58:28 2003 +0000
@@ -48,6 +48,15 @@
 #define OPT_WGAIM_BUDDYWIN_ONTOP        0x00000008
 
 /*
+ *  DATA STRUCTS
+ */
+typedef struct {
+	GtkWidget *win;
+	GtkWidget *slider;
+} slider_win;
+
+
+/*
  *  GLOBALS
  */
 G_MODULE_IMPORT GtkWidget *blist;
@@ -130,10 +139,26 @@
 	return frame;
 }
 
+static slider_win* find_slidwin( GtkWidget *win ) {
+	GList *tmp = window_list;
+
+	while(tmp) {
+		if( ((slider_win*)(tmp->data))->win == win)
+			return (slider_win*)tmp->data;
+		tmp = tmp->next;
+	}
+	return NULL;
+}
+
 gboolean win_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
+	slider_win *slidwin=NULL;
 	/* Remove window from the window list */
 	debug_printf("win2ktrans.dll: Conv window destoyed.. removing from list\n");
-	window_list = g_list_remove(window_list, (gpointer)widget);
+
+	if((slidwin=find_slidwin(widget))) {
+		window_list = g_list_remove(window_list, (gpointer)slidwin);
+		g_free(slidwin);
+	}
 	return FALSE;
 }
 
@@ -152,8 +177,9 @@
 	if ((trans_options & OPT_WGAIM_IMTRANS) &&
 	    (trans_options & OPT_WGAIM_SHOW_IMTRANS)) {
 		/* Look up this window to see if it already has a scroller */
-		if(!g_list_find(window_list, (gpointer)win)) {
+		if(!find_slidwin(win)) {
 			GtkWidget *slider_box=NULL;
+			slider_win *slidwin=NULL;
 		
 			/* Get top vbox */
 			for ( wl1 = wl = gtk_container_get_children(GTK_CONTAINER(win));
@@ -172,8 +198,11 @@
 			gtk_box_pack_start(GTK_BOX(vbox),
 					   slider_box,
 					   FALSE, FALSE, 0);
-			/* Add window to list, to track that it has a scroller */
-			window_list = g_list_append(window_list, (gpointer)win);
+			/* Add window to list, to track that it has a slider */
+			slidwin = g_new0( slider_win, 1 );
+			slidwin->win = win;
+			slidwin->slider = slider_box;
+			window_list = g_list_append(window_list, (gpointer)slidwin);
 			/* Set callback to remove window from the list, if the window is destroyed */
 			g_signal_connect(GTK_OBJECT(win), "destroy_event", G_CALLBACK(win_destroy_cb), NULL);
 		}
@@ -327,7 +356,17 @@
 
 G_MODULE_EXPORT void gaim_plugin_remove() {
 	debug_printf("Removing win2ktrans.dll plugin\n");
+
+	/* Remove slider bars */
 	if(window_list) {
+		GList *tmp=window_list;
+		while(tmp) {
+			slider_win *slidwin = (slider_win*)tmp->data;
+			gtk_widget_destroy(slidwin->slider);
+			set_wintrans_off(slidwin->win);
+			g_free(slidwin);
+			tmp=tmp->next;
+		}
 		g_list_free(window_list);
 		window_list = NULL;
 	}