pidgin/pidgin

Parents 50a483611feb
Children 5c21747ff7dc
When a Contact is added to a Person set the Contact's Person to that Person.

Also fixed a leak in the unit tests that valgrind wasn't seeing for some reason.

Testing Done:
Ran the unittests under valgrind.

Reviewed at https://reviews.imfreedom.org/r/1863/
--- a/libpurple/purpleperson.c Thu Sep 29 06:30:35 2022 -0500
+++ b/libpurple/purpleperson.c Thu Sep 29 21:44:01 2022 -0500
@@ -418,6 +418,8 @@
person, 0);
}
+ purple_contact_set_person(contact, person);
+
purple_person_sort_contacts(person);
}
@@ -450,6 +452,8 @@
person);
}
+ purple_contact_set_person(contact, NULL);
+
purple_person_sort_contacts(person);
}
--- a/libpurple/tests/test_person.c Thu Sep 29 06:30:35 2022 -0500
+++ b/libpurple/tests/test_person.c Thu Sep 29 21:44:01 2022 -0500
@@ -112,6 +112,7 @@
PurpleAccount *account = NULL;
PurpleContact *contact = NULL;
PurplePerson *person = NULL;
+ PurplePerson *person1 = NULL;
guint n_items = 0;
gboolean removed = FALSE;
gboolean changed = FALSE;
@@ -129,6 +130,9 @@
g_assert_cmpuint(n_items, ==, 1);
g_assert_true(changed);
+ person1 = purple_contact_get_person(contact);
+ g_assert_true(person1 == person);
+
changed = FALSE;
removed = purple_person_remove_contact(person, contact);
@@ -137,8 +141,12 @@
g_assert_cmpuint(n_items, ==, 0);
g_assert_true(changed);
+ person1 = purple_contact_get_person(contact);
+ g_assert_null(person1);
+
g_clear_object(&person);
g_clear_object(&account);
+ g_clear_object(&contact);
}
static void