Commit bea16f68 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

fixed memory leaks concerning remove_link

Mon Aug 03 03:04:44 1998  George Lebl  <jirka@5z.com>

        * *.(c|cc): fixed memory leaks concerning remove_link

        * panel-util.[ch]: added a glist pop routine

        * menu.c: restore the grab on the parent menu after the popup
          was "deactivated"
parent 0aea0f9d
Mon Aug 03 03:04:44 1998 George Lebl <jirka@5z.com>
* *.(c|cc): fixed memory leaks concerning remove_link
* panel-util.[ch]: added a glist pop routine
* menu.c: restore the grab on the parent menu after the popup
was "deactivated"
Sat Aug 01 20:55:12 1998 George Lebl <jirka@5z.com>
* menu.c: fixed main menu addition segfault
......
Mon Aug 03 03:04:44 1998 George Lebl <jirka@5z.com>
* *.(c|cc): fixed memory leaks concerning remove_link
* panel-util.[ch]: added a glist pop routine
* menu.c: restore the grab on the parent menu after the popup
was "deactivated"
Sat Aug 01 20:55:12 1998 George Lebl <jirka@5z.com>
* menu.c: fixed main menu addition segfault
......
......@@ -580,8 +580,8 @@ gnome_panel_applet_cleanup(int applet_id)
if(info->applet_id == applet_id) {
g_free(info->name);
g_list_remove_link(applet_callbacks,list);
g_list_free(list);
g_free(info);
}
list = nlist;
}
......
......@@ -99,8 +99,7 @@ panel_clean_applet(int applet_id)
if(umenu->text)
g_free(umenu->text);
g_free(umenu);
info->user_menu = g_list_remove_link(info->user_menu,
info->user_menu);
info->user_menu = my_g_list_pop_first(info->user_menu);
}
mulapp_remove_empty_from_list();
}
......
......@@ -106,7 +106,7 @@ exec_queue_start_next(void)
if(eq->param) g_free(eq->param);
g_free(eq);
exec_queue = g_list_remove_link(exec_queue,exec_queue);
exec_queue = my_g_list_pop_first(exec_queue);
/*repeat while we are doing applets that do not require a wait
(second invocations of multi applets)*/
} while(ret);
......
......@@ -140,6 +140,7 @@ sigchld_handler(int type)
g_free(child);
children=g_list_remove_link(children,list);
g_list_free(list);
return;
}
}
......
......@@ -212,7 +212,7 @@ add_drawers_from_dir(char *dirname, char *name, int pos, PanelWidget *panel)
}
g_free(filename);
g_free(list->data);
list = g_list_remove_link(list,list);
list = my_g_list_pop_first(list);
}
}
......@@ -237,6 +237,54 @@ add_menu_to_panel (GtkWidget *widget, void *data)
load_menu_applet(NULL,0, 0, current_panel);
}
/*most of this function stolen from the real gtk_menu_popup*/
static void
restore_grabs(GtkWidget *w, gpointer data)
{
GtkWidget *menu_item = data;
GtkMenu *menu = GTK_MENU(menu_item->parent);
GtkWidget *xgrab_shell;
GtkWidget *parent;
/* Find the last viewable ancestor, and make an X grab on it
*/
parent = GTK_WIDGET (menu);
xgrab_shell = NULL;
while (parent) {
gboolean viewable = TRUE;
GtkWidget *tmp = parent;
while (tmp) {
if (!GTK_WIDGET_MAPPED (tmp)) {
viewable = FALSE;
break;
}
tmp = tmp->parent;
}
if (viewable)
xgrab_shell = parent;
parent = GTK_MENU_SHELL (parent)->parent_menu_shell;
}
/*only grab if this HAD a grab before*/
if (xgrab_shell && (GTK_MENU_SHELL (xgrab_shell)->have_xgrab)) {
GdkCursor *cursor = gdk_cursor_new (GDK_ARROW);
GTK_MENU_SHELL (xgrab_shell)->have_xgrab =
(gdk_pointer_grab (xgrab_shell->window, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK,
NULL, cursor, 0) == 0);
gdk_cursor_destroy (cursor);
}
gtk_grab_add (GTK_WIDGET (menu));
}
static int
show_item_menu(GtkWidget *w, GdkEvent *event, gpointer data)
{
......@@ -257,6 +305,10 @@ show_item_menu(GtkWidget *w, GdkEvent *event, gpointer data)
if(!menu) {
menu = gtk_menu_new ();
gtk_object_set_data(GTK_OBJECT(w),"menu",menu);
gtk_signal_connect(GTK_OBJECT(menu),"deactivate",
GTK_SIGNAL_FUNC(restore_grabs),
w->parent->parent);
if(type == 1) {
menuitem = gtk_menu_item_new ();
......@@ -543,7 +595,7 @@ destroy_mf(MenuFinfo *mf)
FileInfo *fi = mf->finfo->data;
if(fi->name) g_free(fi->name);
g_free(fi);
mf->finfo = g_list_remove_link(mf->finfo, mf->finfo);
mf->finfo = my_g_list_pop_first(mf->finfo);
}
if(mf->menudir) g_free(mf->menudir);
if(mf->dir_name) g_free(mf->dir_name);
......@@ -559,7 +611,7 @@ menu_destroy(GtkWidget *menu, gpointer data)
while(mfl) {
MenuFinfo *mf = mfl->data;
destroy_mf(mf);
mfl = g_list_remove_link(mfl,mfl);
mfl = my_g_list_pop_first(mfl);
}
gtk_object_set_data(GTK_OBJECT(menu),"mf",NULL);
return FALSE;
......@@ -665,8 +717,7 @@ check_and_reread(GtkWidget *menuw,Menu *menu,int main_menu)
while(free_list) {
MenuFinfo *mf = free_list->data;
destroy_mf(mf);
free_list = g_list_remove_link(free_list,
free_list);
free_list = my_g_list_pop_first(free_list);
}
}
}
......@@ -797,7 +848,7 @@ create_menu_at (GtkWidget *menu,
thisfile = flist->data;
filename = g_concat_dir_and_file(menudir,thisfile);
flist = g_list_remove_link(flist,flist);
flist = my_g_list_pop_first(flist);
if (stat (filename, &s) == -1) {
g_free (filename);
......
......@@ -56,6 +56,7 @@ mulapp_remove_empty_from_list(void)
multiple_applet_load_list =
g_list_remove_link(multiple_applet_load_list,
list);
g_list_free(list);
if(mq->params) g_warning("Whoops! there were applets "
"to be started while the "
"main one disappeared, this "
......@@ -144,7 +145,7 @@ mulapp_add_ior_and_free_queue(const char *path, const char *ior)
while(li) {
send_applet_start_new_applet(mq->ior,li->data);
g_free(li->data);
li = g_list_remove_link(li,li);
li = my_g_list_pop_first(li);
}
return;
}
......
......@@ -597,8 +597,8 @@ gnome_panel_applet_cleanup(int applet_id)
if(info->applet_id == applet_id) {
g_free(info->name);
g_list_remove_link(applet_callbacks,list);
g_list_free(list);
g_free(info);
}
list = nlist;
}
......
......@@ -293,3 +293,11 @@ resize_window(GtkWidget *widget, int w, int h)
/* FIXME: this should draw only the newly exposed area! */
gtk_widget_draw(widget, NULL);
}
GList *
my_g_list_pop_first(GList *list)
{
GList *r = g_list_remove_link(list,list);
g_list_free(list);
return r;
}
......@@ -27,6 +27,10 @@ GList * my_g_list_swap_prev(GList *list, GList *dl);
it resorts a single item in the list*/
GList * my_g_list_resort_item(GList *list, gpointer data, GCompareFunc func);
/*pop and free the first list link*/
GList * my_g_list_pop_first(GList *list);
/*this is used to do an immediate move instead of set_uposition, which
queues one*/
void move_resize_window(GtkWidget *widget, int x, int y, int w, int h);
......
......@@ -797,7 +797,7 @@ panel_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
gtk_signal_emit(GTK_OBJECT(panel),
panel_widget_signals[APPLET_MOVE_SIGNAL],
ad->applet);
send_move = g_list_remove_link(send_move,send_move);
send_move = my_g_list_pop_first(send_move);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment