SF.net SVN: geany:[4305] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Oct 12 16:31:38 UTC 2009
Revision: 4305
http://geany.svn.sourceforge.net/geany/?rev=4305&view=rev
Author: ntrel
Date: 2009-10-12 16:31:38 +0000 (Mon, 12 Oct 2009)
Log Message:
-----------
Fix memory leaks with gtk_container_get_children().
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/templates.c
trunk/src/tools.c
trunk/src/ui_utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-10-12 16:19:11 UTC (rev 4304)
+++ trunk/ChangeLog 2009-10-12 16:31:38 UTC (rev 4305)
@@ -16,11 +16,13 @@
src/project.c, src/search.c, src/editor.c, src/ui_utils.c,
plugins/classbuilder.c:
Make utils_free_pointers() take 4 arguments, add to API.
+ * src/templates.c, src/tools.c, src/ui_utils.c:
+ Fix memory leaks with gtk_container_get_children().
2009-10-12 Lex Trotman <elextr(at)gmail(dot)com>
- * build.c:
+ * src/build.c:
Ensure that old style build config is not loaded if it does not exist.
Modified: trunk/src/templates.c
===================================================================
--- trunk/src/templates.c 2009-10-12 16:19:11 UTC (rev 4304)
+++ trunk/src/templates.c 2009-10-12 16:31:38 UTC (rev 4305)
@@ -687,6 +687,8 @@
{
gtk_widget_destroy(GTK_WIDGET(item->data));
}
+ g_list_free(children);
+
/* Shouldn't unrefing destroy children anyway? */
g_object_unref(new_with_template_menu);
new_with_template_menu = NULL;
Modified: trunk/src/tools.c
===================================================================
--- trunk/src/tools.c 2009-10-12 16:19:11 UTC (rev 4304)
+++ trunk/src/tools.c 2009-10-12 16:31:38 UTC (rev 4305)
@@ -343,30 +343,28 @@
{
/* get all hboxes which contain a label and an entry element */
GList *children = gtk_container_get_children(GTK_CONTAINER(cc.box));
- GList *tmp;
+ GList *node, *list;
GSList *result_list = NULL;
gint j = 0;
gint len = 0;
gchar **result = NULL;
const gchar *text;
- while (children != NULL)
+ foreach_list(node, children)
{
/* get the contents of each hbox */
- tmp = gtk_container_get_children(GTK_CONTAINER(children->data));
+ list = gtk_container_get_children(GTK_CONTAINER(node->data));
/* first element of the list is the label, so skip it and get the entry element */
- tmp = tmp->next;
+ text = gtk_entry_get_text(GTK_ENTRY(list->next->data));
- text = gtk_entry_get_text(GTK_ENTRY(tmp->data));
-
/* if the content of the entry is non-empty, add it to the result array */
if (text[0] != '\0')
{
result_list = g_slist_append(result_list, g_strdup(text));
len++;
}
- children = children->next;
+ g_list_free(list);
}
/* create a new null-terminated array but only if there any commands defined */
if (len > 0)
@@ -400,7 +398,7 @@
GeanyDocument *doc = document_get_current();
gint i, len;
gboolean enable;
- GList *children;
+ GList *children, *node;
g_return_if_fail(doc != NULL);
@@ -409,15 +407,15 @@
children = gtk_container_get_children(GTK_CONTAINER(user_data));
len = g_list_length(children);
i = 0;
- while (children != NULL)
+ foreach_list(node, children)
{
if (i == (len - 2))
break; /* stop before the last two elements (the seperator and the set entry) */
- gtk_widget_set_sensitive(GTK_WIDGET(children->data), enable);
- children = children->next;
+ gtk_widget_set_sensitive(GTK_WIDGET(node->data), enable);
i++;
}
+ g_list_free(children);
}
@@ -484,23 +482,20 @@
GtkMenu *menu_edit = GTK_MENU(ui_lookup_widget(main_widgets.window, "send_selection_to2_menu"));
GtkMenu *menu_popup = GTK_MENU(ui_lookup_widget(main_widgets.editor_menu, "send_selection_to1_menu"));
GtkWidget *item;
- GList *me_children;
+ GList *me_children, *node;
GList *mp_children;
static gboolean signal_set = FALSE;
/* first clean the menus to be able to rebuild them */
me_children = gtk_container_get_children(GTK_CONTAINER(menu_edit));
mp_children = gtk_container_get_children(GTK_CONTAINER(menu_popup));
- while (me_children != NULL)
- {
- gtk_widget_destroy(GTK_WIDGET(me_children->data));
- gtk_widget_destroy(GTK_WIDGET(mp_children->data));
+ foreach_list(node, me_children)
+ gtk_widget_destroy(GTK_WIDGET(node->data));
+ foreach_list(node, mp_children)
+ gtk_widget_destroy(GTK_WIDGET(node->data));
+ g_list_free(me_children);
+ g_list_free(mp_children);
- me_children = me_children->next;
- mp_children = mp_children->next;
- }
-
-
if (ui_prefs.custom_commands == NULL || g_strv_length(ui_prefs.custom_commands) == 0)
{
item = gtk_menu_item_new_with_label(_("No custom commands defined."));
Modified: trunk/src/ui_utils.c
===================================================================
--- trunk/src/ui_utils.c 2009-10-12 16:19:11 UTC (rev 4304)
+++ trunk/src/ui_utils.c 2009-10-12 16:31:38 UTC (rev 4305)
@@ -1109,6 +1109,7 @@
item = g_list_find_custom(children, utf8_filename, (GCompareFunc) find_recent_file_item);
if (item != NULL)
gtk_widget_destroy(GTK_WIDGET(item->data));
+ g_list_free(children);
if (grf->toolbar != NULL)
{
@@ -1116,6 +1117,7 @@
item = g_list_find_custom(children, utf8_filename, (GCompareFunc) find_recent_file_item);
if (item != NULL)
gtk_widget_destroy(GTK_WIDGET(item->data));
+ g_list_free(children);
}
/* now prepend a new menuitem for the filename,
* first for the recent files menu in the menu bar */
@@ -1158,6 +1160,8 @@
item = g_list_next(item);
}
}
+ g_list_free(children);
+
/* create item for the menu bar menu */
tmp = gtk_menu_item_new_with_label(filename);
gtk_widget_show(tmp);
@@ -1178,6 +1182,8 @@
item = g_list_next(item);
}
}
+ g_list_free(children);
+
/* create item for the tool bar menu */
tmp = gtk_menu_item_new_with_label(filename);
gtk_widget_show(tmp);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list