[gnome-contacts] Avatar: also provide a fallback if contact == null



commit ad0778f91d2d13114432f2d848bc1ba71185286d
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Sat Jan 20 16:03:36 2018 +0100

    Avatar: also provide a fallback if contact == null

 src/contacts-avatar.vala |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/src/contacts-avatar.vala b/src/contacts-avatar.vala
index 286ff95..7b7d8f8 100644
--- a/src/contacts-avatar.vala
+++ b/src/contacts-avatar.vala
@@ -117,10 +117,8 @@ public class Contacts.Avatar : DrawingArea {
   }
 
   private void calculate_color () {
-    //XXX find something if this.contact == nulll or id == ""
-
-    // We use the hash of the id so we get the same color for a contact
-    var hash = str_hash (this.contact.individual.id);
+    // We use the hash of the id so we get the same color each time for the same contact
+    var hash = (this.contact != null)? str_hash (this.contact.individual.id) : Gdk.CURRENT_TIME;
 
     var r = ((hash & 0xFF0000) >> 16) / 255.0;
     var g = ((hash & 0x00FF00) >> 8) / 255.0;


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