[california] Create/Update Event dialog calendar index mismatch: Closes bgo#727042



commit 1fa83e60fc92250f16d66ec3e9e5d74b8c216cc8
Author: Jim Nelson <jim yorba org>
Date:   Tue Mar 25 15:36:41 2014 -0700

    Create/Update Event dialog calendar index mismatch: Closes bgo#727042
    
    If calendar(s) are disabled/invisible in the calendar manager, there
    could be an index mismatch between the combo list and the list of
    active calendars.  This meant creating or updating a calendar could
    occur on the wrong one, potentially leading to permission problems.

 src/host/host-create-update-event.vala |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/host/host-create-update-event.vala b/src/host/host-create-update-event.vala
index 55606ac..59a4968 100644
--- a/src/host/host-create-update-event.vala
+++ b/src/host/host-create-update-event.vala
@@ -167,9 +167,16 @@ public class CreateUpdateEvent : Gtk.Grid, Interaction {
         calendar_sources = Backing.Manager.instance.get_sources_of_type<Backing.CalendarSource>();
         index = 0;
         int calendar_source_index = 0;
-        foreach (Backing.Source source in calendar_sources) {
-            if (!source.visible)
+        Gee.Iterator<Backing.Source> iter = calendar_sources.iterator();
+        while (iter.next()) {
+            Backing.Source source = iter.get();
+            
+            // drop from List to ensure ComboBox indices match array indices
+            if (!source.visible) {
+                iter.remove();
+                
                 continue;
+            }
             
             calendar_combo.append_text(source.title);
             if (source == event.calendar_source)


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