[california/wip/732671-double] More debug and a potential fix



commit 0b2f7a4081bc948b1c277235d2755a99db0046bd
Author: Jim Nelson <jim yorba org>
Date:   Thu Sep 4 16:57:57 2014 -0700

    More debug and a potential fix

 src/component/component-event.vala      |    8 ++++++++
 src/view/common/common-events-cell.vala |   12 ++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/component/component-event.vala b/src/component/component-event.vala
index ed3e2ed..10ffc5c 100644
--- a/src/component/component-event.vala
+++ b/src/component/component-event.vala
@@ -400,6 +400,14 @@ public class Event : Instance, Gee.Comparable<Event> {
         if (this == other)
             return 0;
         
+        // look for equality first, then worry about sort order
+        if (uid.equal_to(other.uid)) {
+            if (rid != null && other.rid != null && rid.equal_to(other.rid))
+                return 0;
+            else if (rid == null && other.rid == null)
+                return 0;
+        }
+        
         // sort all-day events before timed events
         if (is_all_day && !other.is_all_day)
             return -1;
diff --git a/src/view/common/common-events-cell.vala b/src/view/common/common-events-cell.vala
index e3931a8..b4df56e 100644
--- a/src/view/common/common-events-cell.vala
+++ b/src/view/common/common-events-cell.vala
@@ -223,8 +223,12 @@ internal abstract class EventsCell : Gtk.EventBox, InstanceContainer {
     }
     
     public void add_event(Component.Event event) {
-        if (!sorted_events.add(event))
+        if (!sorted_events.add(event)) {
+            debug("Unable to add event %s to cell for %s: already present", event.uid.to_string(),
+                date.to_string());
+            
             return;
+        }
         
         // subscribe to interesting mutable properties
         event.notify[Component.Event.PROP_SUMMARY].connect(queue_draw);
@@ -237,8 +241,12 @@ internal abstract class EventsCell : Gtk.EventBox, InstanceContainer {
     }
     
     private bool internal_remove_event(Component.Event event) {
-        if (!sorted_events.remove(event))
+        if (!sorted_events.remove(event)) {
+            debug("Unable to remove event %s from cell for %s: not present in sorted_events",
+                event.uid.to_string(), date.to_string());
+            
             return false;
+        }
         
         event.notify[Component.Event.PROP_SUMMARY].disconnect(queue_draw);
         event.notify[Component.Event.PROP_DATE_SPAN].disconnect(on_span_updated);


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