[folks] Fix checks for empty and equal StructuredNames



commit 45a0b1dd7b4384b2f11555c7dfb61dbfacb30de1
Author: Raul Gutierrez Segales <raul gutierrez segales collabora co uk>
Date:   Tue Mar 22 21:35:57 2011 +0000

    Fix checks for empty and equal StructuredNames

 NEWS                  |    1 +
 folks/individual.vala |   18 +++++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/NEWS b/NEWS
index 4119764..2bfed89 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ Bugs fixed:
 * Crasher when reconnecting a Telepathy account
 * Bug 645680 â?? Use random integer IDs for Kf.Personas
 * Bug 645475 â?? Linker warnings for Tracker backend tests
+* Bug 645570 â?? Fix checks for empty and equal StructuredNames
 
 API changes:
 * Add equal () to StructuredName
diff --git a/folks/individual.vala b/folks/individual.vala
index fca2136..39e3067 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -946,21 +946,29 @@ public class Folks.Individual : Object,
 
   private void _update_structured_name ()
     {
+      bool name_found = false;
+
       foreach (var persona in this._persona_list)
         {
           var name_details = persona as NameDetails;
           if (name_details != null)
             {
               var new_value = name_details.structured_name;
-              if (new_value != null)
+              if (new_value != null && !new_value.is_empty ())
                 {
-                  if (new_value != this.structured_name)
-                    this.structured_name = new_value;
-
-                  break;
+                  name_found = true;
+                  if (this.structured_name == null ||
+                      !this.structured_name.equal (new_value))
+                    {
+                      this.structured_name = new_value;
+                      return;
+                    }
                 }
             }
         }
+
+      if (name_found == false)
+        this.structured_name = null;
     }
 
   private void _update_full_name ()



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