From 3a2581b68c8c83875d43ea0f0cbb98e5bf7e6661 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Fri, 12 Jul 2024 11:46:21 +0200 Subject: [PATCH] contact-pane: Make sure to ref created individual Fixes: https://gitlab.gnome.org/GNOME/gnome-contacts/-/issues/356 --- src/contacts-contact-pane.vala | 2 +- src/contacts-import-operation.vala | 2 +- src/core/contacts-contact.vala | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala index 17e2ec36..a8309fad 100644 --- a/src/contacts-contact-pane.vala +++ b/src/contacts-contact-pane.vala @@ -169,7 +169,7 @@ public class Contacts.ContactPane : Adw.Bin { // The new individual. Even when editing an exisiting contact, it might // be a different Individual than before, so make sure to adjust our // selected contact afterwards - unowned var individual = + var individual = yield contact.apply_changes (this.store.aggregator.primary_store); debug ("Applied changes resulted in individual (%s)", (individual != null)? individual.id : "null"); diff --git a/src/contacts-import-operation.vala b/src/contacts-import-operation.vala index 54a29a3d..3eba4755 100644 --- a/src/contacts-import-operation.vala +++ b/src/contacts-import-operation.vala @@ -42,7 +42,7 @@ public class Contacts.ImportOperation : Operation { for (uint i = 0; i < this.to_import.get_n_items (); i++) { var contact = (Contact) this.to_import.get_item (i); - unowned var individual = yield contact.apply_changes (primary_store); + var individual = yield contact.apply_changes (primary_store); if (individual != null) { debug ("Created new individual (%s)", (individual != null)? individual.id : "null"); diff --git a/src/core/contacts-contact.vala b/src/core/contacts-contact.vala index c267215a..1a9e5abf 100644 --- a/src/core/contacts-contact.vala +++ b/src/core/contacts-contact.vala @@ -269,8 +269,8 @@ public class Contacts.Contact : GLib.Object, GLib.ListModel { * * Returns the Individual that was created from applying the changes */ - public async unowned Individual? apply_changes (PersonaStore store) throws GLib.Error { - unowned Individual? individual = null; + public async Individual? apply_changes (PersonaStore store) throws GLib.Error { + Individual? individual = null; // Create a (shallow) copy of the chunks var chunks = this.chunks.copy ((chunk) => { return chunk; }); -- GitLab