From: Jim S. <jse...@us...> - 2002-05-15 02:21:25
|
Update of /cvsroot/gaim/gaim/src In directory usw-pr-cvs1:/tmp/cvs-serv12342/src Modified Files: buddy_chat.c conversation.c gtkimhtml.c Log Message: Eliminated memory leaks resulting from the way pop-up menus are used. Index: buddy_chat.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/buddy_chat.c,v retrieving revision 1.151 retrieving revision 1.152 diff -u -d -r1.151 -r1.152 --- buddy_chat.c 6 May 2002 19:32:59 -0000 1.151 +++ buddy_chat.c 15 May 2002 02:21:21 -0000 1.152 @@ -846,8 +846,15 @@ c = new_conversation(gtk_object_get_user_data(obj)); set_convo_gc(c, b->gc); } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { - GtkWidget *menu; + static GtkWidget *menu = NULL; GtkWidget *button; + + /* + * If a menu already exists, destroy it before creating a new one, + * thus freeing-up the memory it occupied. + */ + if(menu) + gtk_widget_destroy(menu); menu = gtk_menu_new(); Index: conversation.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/conversation.c,v retrieving revision 1.352 retrieving revision 1.353 diff -u -d -r1.352 -r1.353 --- conversation.c 5 May 2002 01:16:45 -0000 1.352 +++ conversation.c 15 May 2002 02:21:21 -0000 1.353 @@ -3441,13 +3441,20 @@ static gboolean icon_menu(GtkObject *obj, GdkEventButton *e, struct conversation *c) { - GtkWidget *menu; + static GtkWidget *menu = NULL; GtkWidget *button; if (e->button != 3) return FALSE; if (e->type != GDK_BUTTON_PRESS) return FALSE; + + /* + * If a menu already exists, destroy it before creating a new one, + * thus freeing-up the memory it occupied. + */ + if(menu) + gtk_widget_destroy(menu); menu = gtk_menu_new(); Index: gtkimhtml.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkimhtml.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -d -r1.107 -r1.108 --- gtkimhtml.c 5 May 2002 01:06:15 -0000 1.107 +++ gtkimhtml.c 15 May 2002 02:21:21 -0000 1.108 @@ -1764,8 +1764,17 @@ uw = click->data; if ((x > uw->x) && (x < uw->x + uw->width) && (y > uw->y) && (y < uw->y + uw->height)) { - GtkWidget *menu = gtk_menu_new (); + static GtkWidget *menu = NULL; GtkWidget *button; + + /* + * If a menu already exists, destroy it before creating a new one, + * thus freeing-up the memory it occupied. + */ + if(menu) + gtk_widget_destroy(menu); + + menu = gtk_menu_new(); if (uw->bit->url) { button = gtk_menu_item_new_with_label ("Open URL"); |