Mercurial > pidgin.yaz
changeset 3250:0970eabdd8df
[gaim-migrate @ 3268]
Eliminated memory leaks resulting from the way pop-up menus are used.
committer: Tailor Script <tailor@pidgin.im>
author | Jim Seymour <jseymour> |
---|---|
date | Wed, 15 May 2002 02:21:21 +0000 |
parents | dbbdf3a55999 |
children | b3c7af7286de |
files | src/buddy_chat.c src/conversation.c src/gtkimhtml.c |
diffstat | 3 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/buddy_chat.c Tue May 14 18:24:30 2002 +0000 +++ b/src/buddy_chat.c Wed May 15 02:21:21 2002 +0000 @@ -846,9 +846,16 @@ 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(); button = gtk_menu_item_new_with_label(_("IM"));
--- a/src/conversation.c Tue May 14 18:24:30 2002 +0000 +++ b/src/conversation.c Wed May 15 02:21:21 2002 +0000 @@ -3441,7 +3441,7 @@ static gboolean icon_menu(GtkObject *obj, GdkEventButton *e, struct conversation *c) { - GtkWidget *menu; + static GtkWidget *menu = NULL; GtkWidget *button; if (e->button != 3) @@ -3449,6 +3449,13 @@ 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(); if (c->icon_timer) {
--- a/src/gtkimhtml.c Tue May 14 18:24:30 2002 +0000 +++ b/src/gtkimhtml.c Wed May 15 02:21:21 2002 +0000 @@ -1764,9 +1764,18 @@ 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"); gtk_signal_connect (GTK_OBJECT (button), "activate",