Mercurial > pidgin
changeset 25374:f648144bc93d
A slightly "warmenhoved" patch from Jon Turney to prevent some unnecessary
processing of status changes when there haven't been any actual changes.
Fixes #7081
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Tue, 27 Jan 2009 04:22:53 +0000 |
parents | 3d456ca75ed9 |
children | c7e4ec5c30b1 |
files | COPYRIGHT libpurple/status.c |
diffstat | 2 files changed, 30 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/COPYRIGHT Tue Jan 27 03:32:11 2009 +0000 +++ b/COPYRIGHT Tue Jan 27 04:22:53 2009 +0000 @@ -444,6 +444,7 @@ Todd Troxell Brad Turcotte Kyle Turman +Jon Turney Junichi Uekawa Igor Vlasenko István Váradi
--- a/libpurple/status.c Tue Jan 27 03:32:11 2009 +0000 +++ b/libpurple/status.c Tue Jan 27 04:22:53 2009 +0000 @@ -816,28 +816,42 @@ /* Reset any unspecified attributes to their default value */ status_type = purple_status_get_type(status); l = purple_status_type_get_attrs(status_type); - while (l != NULL) - { + while (l != NULL) { PurpleStatusAttr *attr; attr = l->data; - if (!g_list_find_custom(specified_attr_ids, attr->id, (GCompareFunc)strcmp)) - { + l = l->next; + + if (!g_list_find_custom(specified_attr_ids, attr->id, (GCompareFunc)strcmp)) { PurpleValue *default_value; default_value = purple_status_attr_get_value(attr); - if (default_value->type == PURPLE_TYPE_STRING) - purple_status_set_attr_string(status, attr->id, - purple_value_get_string(default_value)); - else if (default_value->type == PURPLE_TYPE_INT) - purple_status_set_attr_int(status, attr->id, - purple_value_get_int(default_value)); - else if (default_value->type == PURPLE_TYPE_BOOLEAN) - purple_status_set_attr_boolean(status, attr->id, - purple_value_get_boolean(default_value)); + if (default_value->type == PURPLE_TYPE_STRING) { + const char *cur = purple_status_get_attr_string(status, attr->id); + const char *def = purple_value_get_string(default_value); + if ((cur == NULL && def == NULL) + || (cur != NULL && def != NULL + && !strcmp(cur, def))) { + continue; + } + + purple_status_set_attr_string(status, attr->id, def); + } else if (default_value->type == PURPLE_TYPE_INT) { + int cur = purple_status_get_attr_int(status, attr->id); + int def = purple_value_get_int(default_value); + if (cur == def) + continue; + + purple_status_set_attr_int(status, attr->id, def); + } else if (default_value->type == PURPLE_TYPE_BOOLEAN) { + gboolean cur = purple_status_get_attr_boolean(status, attr->id); + gboolean def = purple_value_get_boolean(default_value); + if (cur == def) + continue; + + purple_status_set_attr_boolean(status, attr->id, def); + } changed = TRUE; } - - l = l->next; } g_list_free(specified_attr_ids);