Commit b2933740 authored by Scott Reeves's avatar Scott Reeves

memory leaks, performance optimization

svn path=/trunk/; revision=198
parent 359cdf57
2007-02-22 Scott Reeves <sreeves@novell.com>
* libslab/slab-gnome-util.c
* libslab/app-shell.c
* libslab/app-resizer.c
* libslab/application-tile.c:
start of performance optimization work.
valgrind work for memory leaks.
Patch from Jens Granseuer for leaks - BGO 396110
Fix leaks for BGO 395014 based on patch from Paolo Borelli
2007-02-21 Scott Reeves <sreeves@novell.com>
* libslab/app-resizer.c
* libslab/app-shell.c
......
......@@ -86,16 +86,17 @@ app_resizer_init (AppResizer * window)
void
remove_container_entries (GtkContainer * widget)
{
GList *children = gtk_container_get_children (widget);
if (children == NULL)
return;
GList *children, *l;
do
children = gtk_container_get_children (widget);
for (l = children; l; l = l->next)
{
GtkWidget *child = GTK_WIDGET (children->data);
GtkWidget *child = GTK_WIDGET (l->data);
gtk_container_remove (GTK_CONTAINER (widget), GTK_WIDGET (child));
}
while (NULL != (children = g_list_next (children)));
if (children)
g_list_free (children);
}
static void
......
......@@ -84,7 +84,6 @@ static void tile_activated_cb (Tile * tile, TileEvent * event, gpointer user_dat
static void handle_launcher_single_clicked (Tile * launcher, gpointer data);
static void handle_menu_action_performed (Tile * launcher, TileEvent * event, TileAction * action,
gpointer data);
static gint category_name_compare (gconstpointer a, gconstpointer b);
static gint application_launcher_compare (gconstpointer a, gconstpointer b);
static void gmenu_tree_changed_callback (GMenuTree * tree, gpointer user_data);
gboolean regenerate_categories (AppShellData * app_data);
......@@ -869,12 +868,13 @@ generate_categories (AppShellData * app_data)
for (l = contents; l; l = l->next)
{
const char *category;
GMenuTreeItem *item = l->data;
switch (gmenu_tree_item_get_type (l->data))
switch (gmenu_tree_item_get_type (item))
{
case GMENU_TREE_ITEM_DIRECTORY:
category = gmenu_tree_directory_get_name (l->data);
generate_category(category, l->data, app_data, TRUE);
category = gmenu_tree_directory_get_name ((GMenuTreeDirectory*)item);
generate_category(category, (GMenuTreeDirectory*)item, app_data, TRUE);
break;
case GMENU_TREE_ITEM_ENTRY:
need_misc = TRUE;
......@@ -882,7 +882,11 @@ generate_categories (AppShellData * app_data)
default:
break;
}
gmenu_tree_item_unref (item);
}
g_slist_free (contents);
if (need_misc)
generate_category (_("Other"), root_dir, app_data, FALSE);
......@@ -901,26 +905,28 @@ generate_categories (AppShellData * app_data)
static void
generate_category (const char * category, GMenuTreeDirectory * root_dir, AppShellData * app_data, gboolean recursive)
{
CategoryData *data = NULL;
CategoryData *data;
/* This is not needed. GMenu already returns an ordered, non duplicate list
GList *list_entry;
list_entry =
g_list_find_custom (app_data->categories_list, category,
category_name_compare);
if (!list_entry)
{
*/
data = g_new0 (CategoryData, 1);
data->category = g_strdup (category);
app_data->categories_list =
/* use the gmenu order instead of alphabetical */
g_list_insert (app_data->categories_list, data, -1);
g_list_append (app_data->categories_list, data);
/* g_list_insert_sorted (app_data->categories_list, data, category_data_compare); */
/*
}
else
{
data = list_entry->data;
}
*/
if (app_data->hash) /* used to eliminate dups on a per category basis. */
g_hash_table_destroy (app_data->hash);
......@@ -990,10 +996,7 @@ generate_launchers (GMenuTreeDirectory * root_dir, AppShellData * app_data, Cate
contents = gmenu_tree_directory_get_contents (root_dir);
for (l = contents; l; l = l->next)
{
GMenuTreeItemType item_type;
item_type = gmenu_tree_item_get_type (l->data);
switch (item_type)
switch (gmenu_tree_item_get_type (l->data))
{
case GMENU_TREE_ITEM_DIRECTORY:
/* g_message ("Found sub-category %s", gmenu_tree_directory_get_name (l->data)); */
......@@ -1032,6 +1035,8 @@ generate_launchers (GMenuTreeDirectory * root_dir, AppShellData * app_data, Cate
default:
break;
}
gmenu_tree_item_unref (l->data);
}
g_slist_free (contents);
}
......@@ -1280,6 +1285,7 @@ application_launcher_compare (gconstpointer a, gconstpointer b)
return g_ascii_strcasecmp (val1, val2);
}
/*
static gint
category_name_compare (gconstpointer a, gconstpointer b)
{
......@@ -1292,6 +1298,7 @@ category_name_compare (gconstpointer a, gconstpointer b)
}
return g_ascii_strcasecmp (category, data->category);
}
*/
static void
tile_activated_cb (Tile * tile, TileEvent * event, gpointer user_data)
......
......@@ -811,6 +811,7 @@ is_desktop_item_in_user_list (const gchar *uri)
GSList *node;
gint offset;
gint uri_len;
gboolean retval;
retval = FALSE;
......@@ -818,9 +819,10 @@ is_desktop_item_in_user_list (const gchar *uri)
if (! app_list)
return FALSE;
uri_len = strlen (uri);
for (node = app_list; node; node = node->next) {
offset = strlen (uri) - strlen ((gchar *) node->data);
offset = uri_len - strlen ((gchar *) node->data);
if (offset < 0)
offset = 0;
......
......@@ -40,6 +40,7 @@ get_slab_gconf_bool (const gchar * key)
value = gconf_client_get_bool (gconf_client, key, &error);
g_object_unref (gconf_client);
if (error)
g_warning ("error accessing %s [%s]\n", key, error->message);
......@@ -59,6 +60,7 @@ get_slab_gconf_int (const gchar * key)
value = gconf_client_get_int (gconf_client, key, &error);
g_object_unref (gconf_client);
if (error)
g_warning ("error accessing %s [%s]\n", key, error->message);
......@@ -78,6 +80,7 @@ get_slab_gconf_string (const gchar * key)
value = gconf_client_get_string (gconf_client, key, &error);
g_object_unref (gconf_client);
if (error)
g_warning ("error accessing %s [%s]\n", key, error->message);
......@@ -108,6 +111,7 @@ get_slab_gconf_slist (const gchar * key)
value = gconf_client_get_list (gconf_client, key, GCONF_VALUE_STRING, &error);
g_object_unref (gconf_client);
if (error)
{
g_warning ("error accessing %s [%s]\n", key, error->message);
......@@ -195,8 +199,7 @@ get_package_name_from_desktop_item (GnomeDesktopItem * desktop_item)
&retval, &error))
{
g_warning ("error: [%s]\n", error->message);
return NULL;
retval = -1;
}
g_free (argv[4]);
......@@ -226,6 +229,7 @@ open_desktop_item_exec (GnomeDesktopItem * desktop_item)
g_warning ("error launching %s [%s]\n",
gnome_desktop_item_get_location (desktop_item), error->message);
g_error_free (error);
return FALSE;
}
......@@ -257,6 +261,8 @@ open_desktop_item_help (GnomeDesktopItem * desktop_item)
{
g_warning ("error opening %s [%s]\n", help_uri, error->message);
g_free (help_uri);
g_error_free (error);
return FALSE;
}
......@@ -281,24 +287,32 @@ desktop_uri_is_in_main_menu (const gchar * uri)
GSList *node;
gint offset;
gint uri_len;
gboolean found = FALSE;
app_list = get_slab_gconf_slist (SLAB_USER_SPECIFIED_APPS_KEY);
if (!app_list)
return FALSE;
uri_len = strlen (uri);
for (node = app_list; node; node = node->next)
{
offset = strlen (uri) - strlen ((gchar *) node->data);
offset = uri_len - strlen ((gchar *) node->data);
if (offset < 0)
offset = 0;
if (!strcmp (&uri[offset], (gchar *) node->data))
return TRUE;
{
found = TRUE;
break;
}
}
return FALSE;
free_slab_gconf_slist_of_strings (app_list);
return found;
}
gint
......
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