pidgin: 69220525: A slightly "warmenhoved" patch from Jon ...

datallah at pidgin.im datallah at pidgin.im
Mon Jan 26 23:25:27 EST 2009


-----------------------------------------------------------------
Revision: 6922052516b4de648838827a2c1806840619d49a
Ancestor: 324353ef9a60c0717f6a13e738a6aa905ef55422
Author: datallah at pidgin.im
Date: 2009-01-27T04:22:53
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6922052516b4de648838827a2c1806840619d49a

Modified files:
        COPYRIGHT libpurple/status.c

ChangeLog: 

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

-------------- next part --------------
============================================================
--- COPYRIGHT	dec9f511cf7d5f746e7acd54a10bd0756d5096c3
+++ COPYRIGHT	15484f66a1e90dce36f445fc492c9a9c33fdd002
@@ -444,6 +444,7 @@ Kyle Turman
 Todd Troxell
 Brad Turcotte
 Kyle Turman
+Jon Turney
 Junichi Uekawa
 Igor Vlasenko
 Istv?n V?radi
============================================================
--- libpurple/status.c	746d386f0f990633b7f11078989b45602d84f4bb
+++ libpurple/status.c	47963ff3aa3f74db37eec3e1f5788c7f5fe00404
@@ -816,28 +816,42 @@ purple_status_set_active_with_attrs_list
 	/* 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);
 


More information about the Commits mailing list