Add the CONSTRUCT flag to PurpleContactInfo:id as we need it set in the constructor

Tue, 05 Mar 2024 02:04:55 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 05 Mar 2024 02:04:55 -0600
changeset 42624
931b9adb4ab5
parent 42622
7c834e816ea4
child 42625
36732747258f

Add the CONSTRUCT flag to PurpleContactInfo:id as we need it set in the constructor

I found this while trying to rewriting the account serialization code. The id
was being set multiple times when it was passed to g_object_new as that value
was not set before GObjectClass.constructed was called.

Testing Done:
Checked in with turtles, but also used work in progress branch to verify the fix.

Reviewed at https://reviews.imfreedom.org/r/3008/

libpurple/purpleaccount.c file | annotate | diff | comparison | revisions
libpurple/purplecontactinfo.c file | annotate | diff | comparison | revisions
--- a/libpurple/purpleaccount.c	Mon Mar 04 22:26:00 2024 -0600
+++ b/libpurple/purpleaccount.c	Tue Mar 05 02:04:55 2024 -0600
@@ -719,7 +719,7 @@
 
 	/* If we didn't get an id, checksum the protocol id and the username. */
 	id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(object));
-	if(id == NULL) {
+	if(purple_strempty(id)) {
 		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
 		GChecksum *checksum = NULL;
 		const char *username = NULL;
--- a/libpurple/purplecontactinfo.c	Mon Mar 04 22:26:00 2024 -0600
+++ b/libpurple/purplecontactinfo.c	Tue Mar 05 02:04:55 2024 -0600
@@ -336,7 +336,7 @@
 	info = PURPLE_CONTACT_INFO(obj);
 	priv = purple_contact_info_get_instance_private(info);
 
-	if(priv->id == NULL) {
+	if(purple_strempty(priv->id)) {
 		purple_contact_info_set_id(info, NULL);
 	}
 
@@ -378,7 +378,7 @@
 		"id", "id",
 		"The id of the contact",
 		NULL,
-		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+		G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * PurpleContactInfo:username:

mercurial