[evolution-data-server] DataCalView: Created objects could be notified twice



commit 6e20a4e1ec6a7a9b86b963d9fb6bed0ec0746fe9
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 27 16:48:36 2020 +0100

    DataCalView: Created objects could be notified twice
    
    The backend could notify about created objects twice, in which case
    the calendar view scheduled two identical objects for the client
    notification, even only one was enough.

 src/calendar/libedata-cal/e-data-cal-view.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/calendar/libedata-cal/e-data-cal-view.c b/src/calendar/libedata-cal/e-data-cal-view.c
index 3398600c9..aed964107 100644
--- a/src/calendar/libedata-cal/e-data-cal-view.c
+++ b/src/calendar/libedata-cal/e-data-cal-view.c
@@ -726,9 +726,14 @@ notify_add_component (EDataCalView *view,
                       /* const */ ECalComponent *comp)
 {
        ECalClientViewFlags flags;
-       gchar *obj;
+       ECalComponentId *id;
 
-       obj = e_data_cal_view_get_component_string (view, comp);
+       id = e_cal_component_get_id (comp);
+
+       if (!id || g_hash_table_lookup (view->priv->ids, id)) {
+               e_cal_component_id_free (id);
+               return;
+       }
 
        send_pending_changes (view);
        send_pending_removes (view);
@@ -736,17 +741,19 @@ notify_add_component (EDataCalView *view,
        /* Do not send component add notifications during initial stage */
        flags = e_data_cal_view_get_flags (view);
        if (view->priv->complete || (flags & E_CAL_CLIENT_VIEW_FLAGS_NOTIFY_INITIAL) != 0) {
+               gchar *obj;
+
                if (view->priv->adds->len == THRESHOLD_ITEMS)
                        send_pending_adds (view);
+
+               obj = e_data_cal_view_get_component_string (view, comp);
+
                g_array_append_val (view->priv->adds, obj);
 
                ensure_pending_flush_timeout (view);
        }
 
-       g_hash_table_insert (
-               view->priv->ids,
-               e_cal_component_get_id (comp),
-               GUINT_TO_POINTER (1));
+       g_hash_table_insert (view->priv->ids, id, GUINT_TO_POINTER (1));
 }
 
 static void


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