Fix criticals when opening Add a Chat dialog

Sat, 29 Oct 2022 01:37:54 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Sat, 29 Oct 2022 01:37:54 -0500
changeset 41860
9315e7772780
parent 41859
ed82ab63d15a
child 41861
67b0fe9f32f3

Fix criticals when opening Add a Chat dialog

Testing Done:
Opened Add a Chat dialog with `G_DEBUG=fatal-criticals` and didn't crash.

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

pidgin/pidginaddchatdialog.c file | annotate | diff | comparison | revisions
--- a/pidgin/pidginaddchatdialog.c	Sat Oct 29 01:14:13 2022 -0500
+++ b/pidgin/pidginaddchatdialog.c	Sat Oct 29 01:37:54 2022 -0500
@@ -100,16 +100,19 @@
 	GHashTable *defaults = NULL;
 	gboolean focus_set = FALSE;
 
-	account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
-	connection = purple_account_get_connection(account);
-	protocol = purple_account_get_protocol(account);
-
 	/* Clean up the dynamic box and our list of entires. */
 	while((child = gtk_widget_get_first_child(dialog->dynamic_box)) != NULL) {
 		gtk_box_remove(GTK_BOX(dialog->dynamic_box), child);
 	}
 	g_clear_pointer(&dialog->inputs, g_list_free);
 
+	account = pidgin_account_chooser_get_selected(PIDGIN_ACCOUNT_CHOOSER(dialog->account));
+	if(!PURPLE_IS_ACCOUNT(account)) {
+		return;
+	}
+
+	connection = purple_account_get_connection(account);
+	protocol = purple_account_get_protocol(account);
 	info = purple_protocol_chat_info(PURPLE_PROTOCOL_CHAT(protocol),
 	                                 connection);
 	defaults = purple_protocol_chat_info_defaults(PURPLE_PROTOCOL_CHAT(protocol),

mercurial