[gnome-contacts/gnome-42] Wait for store to be quiescent before applying contact changes



commit 9ca65db52ac01d54704a9df456e7280f8e39baa6
Author: Adam Williamson <awilliam redhat com>
Date:   Wed Apr 27 10:10:58 2022 -0700

    Wait for store to be quiescent before applying contact changes
    
    It's not safe to try and add or edit a contact before the store
    is quiescent, it causes crashes.
    
    Signed-off-by: Adam Williamson <awilliam redhat com>
    (cherry picked from commit 50457308b8785874dc9f774013b7eaa6cf1e5068)

 src/contacts-contact-pane.vala | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 97262161..f3323211 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -185,6 +185,16 @@ public class Contacts.ContactPane : Adw.Bin {
     /* Show fake contact to the user */
     /* TODO: block changes to fake contact */
     show_contact_sheet ();
+    // Wait that the store gets quiescent if it isn't already
+    if (!this.store.aggregator.is_quiescent) {
+      ulong signal_id;
+      SourceFunc callback = apply_changes.callback;
+      signal_id = this.store.quiescent.connect (() => {
+        callback ();
+      });
+      yield;
+      disconnect (signal_id);
+    }
     var fake_individual = individual as FakeIndividual;
     if (fake_individual != null && fake_individual.real_individual == null) {
       // Create a new persona in the primary store based on the fake persona


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]