[folks] individual: Change an assertion into a warning and relax its conditions



commit c7318f12dede2d56c64b7e9cddc5a26b77c2c89a
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Wed Nov 20 11:55:05 2013 +0000

    individual: Change an assertion into a warning and relax its conditions
    
    This should fix a crash (probably) caused by a Persona which is in the
    process of being moved between two Individuals emitting a property
    change notification while both Individuals are still connected to its
    ‘notify’ signal.
    
    This is only ‘probably’ because I can’t reproduce the problem.
    
    See: https://bugzilla.redhat.com/show_bug.cgi?id=1031252

 folks/individual.vala |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index 7b3eccd..305a80c 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -1228,14 +1228,23 @@ public class Folks.Individual : Object,
 
   private void _persona_notify_cb (Object obj, ParamSpec ps)
     {
-      assert (obj is Persona);
-      assert (ps.name == "individual" || (obj as Persona).individual == this);
+      var persona = (Persona) obj;  /* will abort on failure */
+
+      if (ps.name != "individual" &&
+          persona.individual != this &&
+          persona.individual != null)
+        {
+          warning ("Notification on property ‘%s’ of Persona %p (‘%s’) where " +
+              "Persona.individual is %p but was expected to be %p.",
+              ps.name, persona, persona.uid, persona.individual, this);
+          return;
+        }
 
       foreach (var notifier in Individual._notifiers)
         {
           if (ps.name == notifier.property)
             {
-              notifier.notify (this, (!) (obj as Persona), ps);
+              notifier.notify (this, persona, ps);
               break;  /* assume all entries in notifiers are unique */
             }
         }


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