# HG changeset patch
# Node ID f0c10116d2df90d13989d2c90422e2102f251b30
# Parent  7b54f6fa1e6ae9fdafc658b3c96d036d71882f94
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -274,35 +274,40 @@
 static void
 parse_current_error(PurpleXmlNode *node, PurpleAccount *account)
 {
-	guint type;
-	char *type_str = NULL, *description = NULL;
-	PurpleXmlNode *child;
-	PurpleConnectionErrorInfo *current_error = NULL;
+	PurpleXmlNode *child = NULL;
+	GError *error = NULL;
+	GQuark domain = 0;
+	int code = 0;
+	const char *message = _("Unknown error");
+	const char *value = NULL;
 
-	child = purple_xmlnode_get_child(node, "type");
-	if (child == NULL || (type_str = purple_xmlnode_get_data(child)) == NULL)
+	child = purple_xmlnode_get_child(node, "domain");
+	if(child == NULL) {
 		return;
-	type = atoi(type_str);
-	g_free(type_str);
+	}
 
-	if(type > PURPLE_CONNECTION_ERROR_OTHER_ERROR) {
-		purple_debug_error("accounts",
-		                   "Invalid PurpleConnectionError value %d found when "
-		                   "loading account information for %s\n",
-		                   type,
-		                   purple_account_get_username(account));
-		type = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
+	value = purple_xmlnode_get_data(child);
+	if(value == NULL) {
+		return;
 	}
 
-	child = purple_xmlnode_get_child(node, "description");
-	if(child) {
-		description = purple_xmlnode_get_data(child);
+	domain = atoi(value);
+
+	child = purple_xmlnode_get_child(node, "code");
+	if(child != NULL) {
+		value = purple_xmlnode_get_data(child);
+		if(value != NULL) {
+			code = atoi(value);
+		}
 	}
-	current_error = purple_connection_error_info_new(type,
-	                                                 (description != NULL) ? description : "");
-	g_free(description);
 
-	purple_account_set_error_info(account, current_error);
+	child = purple_xmlnode_get_child(node, "message");
+	if(child != NULL) {
+		message = purple_xmlnode_get_data(child);
+	}
+
+	error = g_error_new_literal(domain, code, message);
+	purple_account_set_error(account, error);
 }
 
 static PurpleAccount *
diff --git a/libpurple/purpleaccount.c b/libpurple/purpleaccount.c
--- a/libpurple/purpleaccount.c
+++ b/libpurple/purpleaccount.c
@@ -76,7 +76,7 @@
 
 	PurplePresence *presence;
 
-	PurpleConnectionErrorInfo *error_info;
+	GError *error;
 	PurpleNotification *error_notification;
 } PurpleAccountPrivate;
 
@@ -170,12 +170,7 @@
 	connection = purple_protocol_create_connection(protocol, account, password,
 	                                               &error);
 	if(error != NULL) {
-		PurpleContactInfo *info = PURPLE_CONTACT_INFO(account);
-
-		purple_debug_warning("failed to create connection for %s: %s",
-		                     purple_contact_info_get_username(info),
-		                     error->message);
-		g_clear_error(&error);
+		purple_account_set_error(account, error);
 
 		return;
 	}
@@ -184,18 +179,7 @@
 
 	purple_account_set_connection(account, connection);
 	if(!purple_connection_connect(connection, &error)) {
-		PurpleConnectionErrorInfo *error_info = NULL;
-		const char *message = "unknown error";
-
-		if(error != NULL && error->message != NULL) {
-			message = error->message;
-		}
-
-		error_info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_OTHER_ERROR,
-		                                              message);
-		g_clear_error(&error);
-
-		purple_account_set_error_info(account, error_info);
+		purple_account_set_error(account, error);
 	}
 
 	/* Finally remove our reference to the connection. */
@@ -385,19 +369,17 @@
 	gboolean require_password = TRUE;
 
 	can_connect = purple_protocol_can_connect_finish(protocol, result, &error);
-	if(!can_connect || error != NULL) {
-		PurpleConnectionErrorInfo *info = NULL;
-		const char *error_message = _("unknown error");
+	if(error != NULL) {
+		purple_account_set_error(account, error);
+
+		return;
+	}
 
-		if(error != NULL) {
-			error_message = error->message;
-		}
+	if(!can_connect) {
+		error = g_error_new_literal(PURPLE_CONNECTION_ERROR, 0,
+		                            _("Unable to connect for unknown reasons"));
 
-		info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
-		                                        error_message);
-		purple_account_set_error_info(account, info);
-
-		g_clear_error(&error);
+		purple_account_set_error(account, error);
 
 		return;
 	}
@@ -471,36 +453,27 @@
 }
 
 static PurpleXmlNode *
-current_error_to_xmlnode(PurpleConnectionErrorInfo *err) {
-	PurpleXmlNode *node, *child;
-	char type_str[3];
+current_error_to_xmlnode(GError *error) {
+	PurpleXmlNode *node = NULL;
+	PurpleXmlNode *child = NULL;
+	char *value = NULL;
 
 	node = purple_xmlnode_new("current_error");
 
-	if(err == NULL) {
+	if(error == NULL) {
 		return node;
 	}
 
-	/* It doesn't make sense to have transient errors persist across a
-	 * restart.
-	 */
-	if(!purple_connection_error_is_fatal (err->type)) {
-		return node;
-	}
+	child = purple_xmlnode_new_child(node, "domain");
+	purple_xmlnode_insert_data(child, g_quark_to_string(error->domain), -1);
 
-	child = purple_xmlnode_new_child(node, "type");
-	g_snprintf(type_str, sizeof(type_str), "%u", err->type);
-	purple_xmlnode_insert_data(child, type_str, -1);
+	child = purple_xmlnode_new_child(node, "code");
+	value = g_strdup_printf("%d", error->code);
+	purple_xmlnode_insert_data(child, value, -1);
+	g_free(value);
 
-	child = purple_xmlnode_new_child(node, "description");
-	if(err->description) {
-		char *utf8ized = purple_utf8_try_convert(err->description);
-		if(utf8ized == NULL) {
-			utf8ized = g_utf8_make_valid(err->description, -1);
-		}
-		purple_xmlnode_insert_data(child, utf8ized, -1);
-		g_free(utf8ized);
-	}
+	child = purple_xmlnode_new_child(node, "message");
+	purple_xmlnode_insert_data(child, error->message, -1);
 
 	return node;
 }
@@ -591,7 +564,7 @@
 		purple_xmlnode_insert_child(node, child);
 	}
 
-	child = current_error_to_xmlnode(account->error_info);
+	child = current_error_to_xmlnode(account->error);
 	purple_xmlnode_insert_child(node, child);
 
 	return node;
@@ -642,8 +615,12 @@
 		purple_account_set_proxy_info(account, g_value_get_object(value));
 		break;
 	case PROP_ERROR:
+		purple_account_set_error(account, g_value_get_boxed(value));
+		break;
 	case PROP_ERROR_INFO:
+		G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 		purple_account_set_error_info(account, g_value_get_boxed(value));
+		G_GNUC_END_IGNORE_DEPRECATIONS
 		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -694,8 +671,12 @@
 		g_value_set_object(value, purple_account_get_proxy_info(account));
 		break;
 	case PROP_ERROR:
+		g_value_set_boxed(value, purple_account_get_error(account));
+		break;
 	case PROP_ERROR_INFO:
+		G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 		g_value_set_boxed(value, purple_account_get_error_info(account));
+		G_GNUC_END_IGNORE_DEPRECATIONS
 		break;
 	case PROP_CONNECTED:
 		g_value_set_boolean(value, purple_account_is_connected(account));
@@ -744,6 +725,7 @@
 		purple_account_disconnect(account);
 	}
 
+	g_clear_object(&account->error_notification);
 	g_clear_object(&account->gc);
 	g_clear_object(&account->presence);
 
@@ -764,8 +746,7 @@
 
 	g_clear_object(&account->proxy_info);
 
-	g_clear_pointer(&account->error_info, purple_connection_error_info_free);
-	g_clear_object(&account->error_notification);
+	g_clear_error(&account->error);
 
 	g_free(account->user_info);
 	g_free(account->buddy_icon_path);
@@ -941,7 +922,7 @@
 	properties[PROP_ERROR] = g_param_spec_boxed(
 		"error", NULL, NULL,
 		PURPLE_TYPE_CONNECTION_ERROR_INFO,
-		G_PARAM_READWRITE | G_PARAM_DEPRECATED | G_PARAM_STATIC_STRINGS);
+		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * PurpleAccount:error-info:
@@ -958,7 +939,7 @@
 	properties[PROP_ERROR_INFO] = g_param_spec_boxed(
 		"error-info", NULL, NULL,
 		PURPLE_TYPE_CONNECTION_ERROR_INFO,
-		G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+		G_PARAM_READWRITE | G_PARAM_DEPRECATED | G_PARAM_STATIC_STRINGS);
 
 	/**
 	 * PurpleAccount:connected:
@@ -1111,7 +1092,7 @@
 
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	purple_account_set_error_info(account, NULL);
+	purple_account_set_error(account, NULL);
 
 	if(!purple_account_get_enabled(account)) {
 		purple_debug_info("account",
@@ -1176,6 +1157,15 @@
 	account->disconnecting = FALSE;
 }
 
+void
+purple_account_disconnect_with_error(PurpleAccount *account, GError *error) {
+	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+	g_return_if_fail(error != NULL);
+
+	purple_account_disconnect(account);
+	purple_account_set_error(account, error);
+}
+
 gboolean
 purple_account_is_disconnecting(PurpleAccount *account)
 {
@@ -1594,63 +1584,88 @@
 	                                               NULL, NULL, NULL);
 }
 
-const PurpleConnectionErrorInfo *
+GError *
 purple_account_get_error(PurpleAccount *account) {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return purple_account_get_error_info(account);
+	return account->error;
 }
 
 const PurpleConnectionErrorInfo *
 purple_account_get_error_info(PurpleAccount *account) {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
 
-	return account->error_info;
+	if(account->error == NULL) {
+		return NULL;
+	}
+
+	/* We're leaking this for the moment, as this property will be deleted
+	 * shortly.
+	 */
+	return purple_connection_error_info_new(account->error->code,
+	                                        account->error->message);
 }
 
 void
-purple_account_set_error(PurpleAccount *account,
-                         PurpleConnectionErrorInfo *info)
-{
+purple_account_set_error(PurpleAccount *account, GError *error) {
+	PurpleNotificationManager *manager = NULL;
+
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	purple_account_set_error_info(account, info);
+	if(account->error == error) {
+		return;
+	}
+
+	/* Set the new error. */
+	g_clear_error(&account->error);
+	account->error = error;
+
+	manager = purple_notification_manager_get_default();
+
+	/* Clear the old account connection error notification if we have one. */
+	if(PURPLE_IS_NOTIFICATION(account->error_notification)) {
+		if(PURPLE_IS_NOTIFICATION_MANAGER(manager)) {
+			purple_notification_manager_remove(manager,
+			                                   account->error_notification);
+		}
+
+		g_clear_object(&account->error_notification);
+	}
+
+	/* If we have a new error, create a new error notification. */
+	if(error != NULL) {
+		PurpleNotification *notification = NULL;
+
+		notification = purple_notification_connection_error_new(NULL, account);
+
+		if(PURPLE_IS_NOTIFICATION_MANAGER(manager)) {
+			purple_notification_manager_add(manager, notification);
+		}
+
+		account->error_notification = notification;
+	}
+
+	g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_ERROR]);
+
+	purple_accounts_schedule_save();
 }
 
 void
 purple_account_set_error_info(PurpleAccount *account,
                               PurpleConnectionErrorInfo *info)
 {
-	PurpleNotificationManager *manager = NULL;
+	GError *error = NULL;
 
 	g_return_if_fail(PURPLE_IS_ACCOUNT(account));
 
-	if(info == account->error_info) {
-		return;
+	if(info != NULL) {
+		error = g_error_new_literal(PURPLE_CONNECTION_ERROR, info->type,
+		                            info->description);
+
+		purple_connection_error_info_free(info);
 	}
 
-	g_clear_pointer(&account->error_info,
-	                purple_connection_error_info_free);
-	account->error_info = info;
-
-	manager = purple_notification_manager_get_default();
-
-	if(PURPLE_IS_NOTIFICATION(account->error_notification)) {
-		purple_notification_manager_remove(manager,
-		                                   account->error_notification);
-		g_clear_object(&account->error_notification);
-	}
-
-	if(info != NULL) {
-		account->error_notification =
-			purple_notification_connection_error_new(NULL, account, info);
-
-		purple_notification_manager_add(manager, account->error_notification);
-	}
-
-	g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_ERROR]);
-
-	purple_accounts_schedule_save();
+	purple_account_set_error(account, error);
 }
 
 void
diff --git a/libpurple/purpleaccount.h b/libpurple/purpleaccount.h
--- a/libpurple/purpleaccount.h
+++ b/libpurple/purpleaccount.h
@@ -144,6 +144,18 @@
 void purple_account_disconnect(PurpleAccount *account);
 
 /**
+ * purple_account_disconnect_with_error:
+ * @account: The instance.
+ * @error: (transfer full): The #GError.
+ *
+ * Disconnects @account and sets [property@Account:error] to @error.
+ *
+ * Since: 3.0
+ */
+PURPLE_AVAILABLE_IN_3_0
+void purple_account_disconnect_with_error(PurpleAccount *account, GError *error);
+
+/**
  * purple_account_is_disconnecting:
  * @account: The account
  *
@@ -558,8 +570,8 @@
  *
  * Since: 3.0
  */
-PURPLE_DEPRECATED_FOR(purple_account_get_error_info)
-const PurpleConnectionErrorInfo *purple_account_get_error(PurpleAccount *account);
+PURPLE_AVAILABLE_IN_3_0
+GError *purple_account_get_error(PurpleAccount *account);
 
 /**
  * purple_account_get_error_info:
@@ -575,24 +587,26 @@
  *
  * Since: 3.0
  */
-PURPLE_AVAILABLE_IN_3_0
+PURPLE_DEPRECATED_FOR(purple_account_get_error)
 const PurpleConnectionErrorInfo *purple_account_get_error_info(PurpleAccount *account);
 
 /**
  * purple_account_set_error:
- * @account: The account whose error should be set.
- * @info: (nullable) (transfer full): The [struct@Purple.ConnectionErrorInfo]
- *        to set.
+ * @account: The instance.
+ * @error: (nullable) (transfer full): The new #GError.
+ *
+ * Sets the error of @account to @error.
  *
- * Sets the error of @account to @info. Note that setting this won't disconnect
- * the account. This is intended to be called by libpurple when there is a
- * connection failure, when invalid settings are entered in an account editor,
- * or similar situations.
+ * Note that setting this won't disconnect the account. This is intended to be
+ * called by libpurple when there is a connection failure, when invalid
+ * settings are entered in an account editor, or similar situations.
+ *
+ * See also [method@Account.disconnect_with_error].
  *
  * Since: 3.0
  */
-PURPLE_DEPRECATED_FOR(purple_account_set_error_info)
-void purple_account_set_error(PurpleAccount *account, PurpleConnectionErrorInfo *info);
+PURPLE_AVAILABLE_IN_3_0
+void purple_account_set_error(PurpleAccount *account, GError *error);
 
 /**
  * purple_account_set_error_info:
@@ -607,7 +621,7 @@
  *
  * Since: 3.0
  */
-PURPLE_AVAILABLE_IN_3_0
+PURPLE_DEPRECATED_FOR(purple_account_set_error)
 void purple_account_set_error_info(PurpleAccount *account, PurpleConnectionErrorInfo *info);
 
 /**
diff --git a/libpurple/purpleaccountmanager.c b/libpurple/purpleaccountmanager.c
--- a/libpurple/purpleaccountmanager.c
+++ b/libpurple/purpleaccountmanager.c
@@ -540,10 +540,7 @@
 	/* Save the list. */
 	purple_accounts_schedule_save();
 
-	/* Clearing the error ensures that account-error-changed is emitted,
-	 * which is the end of the guarantee that the error's pointer is valid.
-	 */
-	purple_account_set_error_info(account, NULL);
+	purple_account_set_error(account, NULL);
 
 	g_signal_emit(manager, signals[SIG_REMOVED], 0, account);
 
diff --git a/libpurple/purplenotificationconnectionerror.c b/libpurple/purplenotificationconnectionerror.c
--- a/libpurple/purplenotificationconnectionerror.c
+++ b/libpurple/purplenotificationconnectionerror.c
@@ -28,18 +28,14 @@
 
 struct _PurpleNotificationConnectionError {
 	PurpleNotification parent;
-
-	PurpleConnectionErrorInfo *info;
 };
 
 enum {
 	PROP_0,
-	PROP_ERROR_INFO,
 	N_PROPERTIES,
 	/* Overrides */
 	PROP_ACCOUNT,
 };
-static GParamSpec *properties[N_PROPERTIES] = {NULL, };
 
 static void
 purple_notification_connection_error_error_notify_cb(GObject *self,
@@ -52,15 +48,15 @@
 static void
 purple_notification_connection_error_update(PurpleNotification *notification) {
 	PurpleAccount *account = NULL;
-	const PurpleConnectionErrorInfo *error = NULL;
 	PurpleProtocol *protocol = NULL;
+	GError *error = NULL;
 	GObject *obj = G_OBJECT(notification);
 	char *title = NULL;
 	const char *icon_name = "network-error-symbolic";
 	const char *subtitle = NULL;
 
 	account = purple_notification_get_account(notification);
-	error = purple_account_get_error_info(account);
+	error = purple_account_get_error(account);
 
 	protocol = purple_account_get_protocol(account);
 	if(PURPLE_IS_PROTOCOL(protocol)) {
@@ -73,7 +69,7 @@
 	} else {
 		title = g_strdup_printf(_("%s disconnected"),
 		                      purple_account_get_username(account));
-		subtitle = error->description;
+		subtitle = error->message;
 	}
 
 	g_object_freeze_notify(obj);
@@ -86,22 +82,6 @@
 }
 
 static void
-purple_notification_connection_error_set_error_info(PurpleNotificationConnectionError *error,
-                                                    PurpleConnectionErrorInfo *info)
-{
-	if(error->info == info) {
-		return;
-	}
-
-	g_clear_pointer(&error->info, purple_connection_error_info_free);
-	if(info != NULL) {
-		error->info = purple_connection_error_info_copy(info);
-	}
-
-	g_object_notify_by_pspec(G_OBJECT(error), properties[PROP_ERROR_INFO]);
-}
-
-static void
 purple_notification_connection_error_set_account(PurpleNotificationConnectionError *error,
                                                  PurpleAccount *account)
 {
@@ -147,16 +127,6 @@
                     PURPLE_TYPE_NOTIFICATION)
 
 static void
-purple_notification_connection_error_finalize(GObject *obj) {
-	PurpleNotificationConnectionError *error = NULL;
-
-	error = PURPLE_NOTIFICATION_CONNECTION_ERROR(obj);
-	g_clear_pointer(&error->info, purple_connection_error_info_free);
-
-	G_OBJECT_CLASS(purple_notification_connection_error_parent_class)->finalize(obj);
-}
-
-static void
 purple_notification_connection_error_get_property(GObject *obj, guint param_id,
                                                   GValue *value,
                                                   GParamSpec *pspec)
@@ -185,10 +155,6 @@
 	error = PURPLE_NOTIFICATION_CONNECTION_ERROR(obj);
 
 	switch(param_id) {
-	case PROP_ERROR_INFO:
-		purple_notification_connection_error_set_error_info(error,
-		                                                    g_value_get_boxed(value));
-		break;
 	/* Overrides */
 	case PROP_ACCOUNT:
 		purple_notification_connection_error_set_account(error,
@@ -210,24 +176,9 @@
 {
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
 
-	obj_class->finalize = purple_notification_connection_error_finalize;
 	obj_class->get_property = purple_notification_connection_error_get_property;
 	obj_class->set_property = purple_notification_connection_error_set_property;
 
-	/**
-	 * PurpleNotificationConnectionError:info:
-	 *
-	 * The [type@ConnectionErrorInfo] that this notification is for.
-	 *
-	 * Since: 3.0
-	 */
-	properties[PROP_ERROR_INFO] = g_param_spec_boxed(
-		"info", NULL, NULL,
-		PURPLE_TYPE_CONNECTION_ERROR_INFO,
-		G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
-	g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
-
 	g_object_class_override_property(obj_class, PROP_ACCOUNT, "account");
 }
 
@@ -236,16 +187,13 @@
  *****************************************************************************/
 PurpleNotification *
 purple_notification_connection_error_new(const char *id,
-                                         PurpleAccount *account,
-                                         PurpleConnectionErrorInfo *info)
+                                         PurpleAccount *account)
 {
 	g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
-	g_return_val_if_fail(info != NULL, NULL);
 
 	return g_object_new(
 		PURPLE_TYPE_NOTIFICATION_CONNECTION_ERROR,
 		"id", id,
 		"account", account,
-		"info", info,
 		NULL);
 }
diff --git a/libpurple/purplenotificationconnectionerror.h b/libpurple/purplenotificationconnectionerror.h
--- a/libpurple/purplenotificationconnectionerror.h
+++ b/libpurple/purplenotificationconnectionerror.h
@@ -57,7 +57,6 @@
  * purple_notification_connection_error_new:
  * @id: (nullable): An identifier for this notification.
  * @account: The account.
- * @info: The [type@ConnectionErrorInfo] of the error.
  *
  * Creates a new [class@Notification] for a connection error on @account.
  *
@@ -66,7 +65,7 @@
  * Since: 3.0
  */
 PURPLE_AVAILABLE_IN_3_0
-PurpleNotification *purple_notification_connection_error_new(const char *id, PurpleAccount *account, PurpleConnectionErrorInfo *info);
+PurpleNotification *purple_notification_connection_error_new(const char *id, PurpleAccount *account);
 
 G_END_DECLS
 
diff --git a/libpurple/tests/test_notification_manager.c b/libpurple/tests/test_notification_manager.c
--- a/libpurple/tests/test_notification_manager.c
+++ b/libpurple/tests/test_notification_manager.c
@@ -240,10 +240,10 @@
 
 static void
 test_purple_notification_manager_remove_with_account_all(void) {
-	PurpleConnectionErrorInfo *info = NULL;
+	PurpleAccount *account = NULL;
 	PurpleNotificationManager *manager = NULL;
 	PurpleNotification *notification = NULL;
-	PurpleAccount *account = NULL;
+	GError *error = NULL;
 	GListModel *model = NULL;
 
 	/* This test will add 3 notifications to the notification manager for the
@@ -282,11 +282,11 @@
 	g_clear_object(&notification);
 
 	/* Add a connection error notification with the account. */
-	info = purple_connection_error_info_new(PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
-	                                        "the network is borked.");
-	notification = purple_notification_connection_error_new(NULL, account,
-	                                                        info);
-	purple_connection_error_info_free(info);
+	error = g_error_new_literal(PURPLE_CONNECTION_ERROR,
+	                            PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
+	                            "the network is borked.");
+	purple_account_set_error(account, error);
+	notification = purple_notification_connection_error_new(NULL, account);
 	purple_notification_manager_add(manager, notification);
 	g_clear_object(&notification);
 
@@ -321,6 +321,12 @@
 	purple_notification_manager_clear(manager);
 	g_assert_cmpuint(g_list_model_get_n_items(model), ==, 0);
 
+	/* We have a reference cycle between the account and its error
+	 * notification. The dispose method does not get called in this case. So to
+	 * break the stalemate, we just set the error to NULL.
+	 */
+	purple_account_set_error(account, NULL);
+
 	g_assert_finalize_object(manager);
 	g_assert_finalize_object(account);
 }
