From: <aar...@us...> - 2006-07-11 00:43:56
|
Revision: 16481 Author: aaronsheldon Date: 2006-07-10 17:43:51 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16481&view=rev Log Message: ----------- Adds the ability to destroy the status_icon_hash_table after a re-do buddy list and reclaim memory. Uses gstrings instead of *chars in get_status_icon. Adds a / delimiter for hash strings. Disables updating the buddy list each and every time a single node is hidden. Modified Paths: -------------- branches/soc-2006-blist-efficiency/src/gtkblist.c Modified: branches/soc-2006-blist-efficiency/src/gtkblist.c =================================================================== --- branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-10 23:55:24 UTC (rev 16480) +++ branches/soc-2006-blist-efficiency/src/gtkblist.c 2006-07-11 00:43:51 UTC (rev 16481) @@ -2700,12 +2700,19 @@ int y; }; +static void g_string_destroy(GString *destroyable) +{ + g_string_free(destroyable, TRUE); + return; +} + GdkPixbuf * gaim_gtk_blist_get_status_icon(GaimBlistNode *node, GaimStatusIconSize size) { GdkPixbuf *scale, *status = NULL; int i, scalesize = 30; - char *filename, *key, *tmp; + char *filename; + GString *key = g_string_sized_new(16); const char *protoname = NULL; struct _gaim_gtk_blist_node *gtknode = node->ui_data; struct _gaim_gtk_blist_node *gtkbuddynode = NULL; @@ -2716,7 +2723,10 @@ GaimChat *chat = NULL; if (!status_icon_hash_table) - status_icon_hash_table = g_hash_table_new (g_str_hash,g_str_equal); + status_icon_hash_table = g_hash_table_new_full((GHashFunc)g_string_hash, + (GEqualFunc)g_string_equal, + (GDestroyNotify)g_string_destroy, + (GDestroyNotify)gdk_pixbuf_unref); if(GAIM_BLIST_NODE_IS_CONTACT(node)) { if(!gtknode->contact_expanded) { @@ -2788,61 +2798,51 @@ if (buddy) { if (GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) - key = g_strconcat(protoname, "login", NULL); + g_string_append_printf(key, "%s/login", protoname); else if (!GAIM_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) - key = g_strconcat(protoname, "logout", NULL); + g_string_append_printf(key, "%s/logout", protoname); else - key = g_strdup(protoname); + key = g_string_append(key, protoname); presence = gaim_buddy_get_presence(buddy); if (!GAIM_BUDDY_IS_ONLINE(buddy)) { - tmp = key; - key = g_strconcat(key, "off", NULL); - g_free(tmp); + key = g_string_append(key, "/off"); } else if (gaim_presence_is_idle(presence)) { - tmp = key; - key = g_strconcat(key, "idle", NULL); - g_free(tmp); + key = g_string_append(key, "/idle"); } if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy))) { - tmp = key; - key = g_strconcat(key, "blocked", NULL); - g_free(tmp); + key = g_string_append(key, "/priv"); } if (size == GAIM_STATUS_ICON_SMALL) { - tmp = key; - key = g_strconcat(key, "small", NULL); - g_free(tmp); + key = g_string_append(key, "/tiny"); } for(i=0; i<4; i++) { if(emblems[i].filename) { - tmp = key; - key = g_strconcat(key, emblems[i].filename, NULL); - g_free(tmp); + g_string_append_printf(key, "/%s", emblems[i].filename); } } } /* There are only two options for chat or gaimdude - big or small */ else if (chat && size == GAIM_STATUS_ICON_SMALL) - key = g_strconcat(protoname, "chat-s", NULL); + g_string_append_printf(key, "%s-chat-s", protoname); else if (chat) - key = g_strconcat(protoname, "chat", NULL); + g_string_append_printf(key, "%s-chat", protoname); else if (size == GAIM_STATUS_ICON_SMALL) - key = g_strdup("gaimdude-s"); + key = g_string_append(key, "gaimdude-s"); else - key = g_strdup("gaimdude"); + key = g_string_append(key, "gaimdude"); /* End Generating Lookup Key */ /* If we already know this icon, just return it */ - scale = g_hash_table_lookup (status_icon_hash_table, key); + scale = g_hash_table_lookup(status_icon_hash_table, key); if (scale) { gdk_pixbuf_ref(scale); - g_free(key); + g_string_free(key, TRUE); return scale; } @@ -3174,14 +3174,18 @@ if(gtkblist->selected_node == node) gtkblist->selected_node = NULL; - + /* This code seems to be irrelevant. We should not need to update the + * gtkblist before a node is removed and it takes a lot of time to do that. + */ +#if 0 if (get_iter_from_node(node, &iter)) { gtk_tree_store_remove(gtkblist->treemodel, &iter); if(GAIM_BLIST_NODE_IS_CONTACT(node) || GAIM_BLIST_NODE_IS_BUDDY(node) || GAIM_BLIST_NODE_IS_CHAT(node)) { gaim_gtk_blist_update(list, node->parent); - } - } + } + } +#endif gtk_tree_row_reference_free(gtknode->row); gtknode->row = NULL; } @@ -4004,6 +4008,10 @@ gaim_gtk_blist_update(list, node); node = gaim_blist_node_next(node, FALSE); } + + g_hash_table_destroy(status_icon_hash_table); + status_icon_hash_table = NULL; + } void gaim_gtk_blist_refresh(GaimBuddyList *list) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |