[evolution/gnome-3-32] [ECompEditor] Ensure attendee changes stored before save



commit dab5df03ed225d091461a69386a42a0ab29dbb7c
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 28 11:23:18 2019 +0200

    [ECompEditor] Ensure attendee changes stored before save
    
    This makes sure the editor changes are stored in the component
    before the component is saved into the calendar.
    
    This addresses (one of) the reason(s) for a crash reported downstream:
    https://bugzilla.redhat.com/show_bug.cgi?id=1721543

 src/calendar/gui/e-comp-editor.c           | 23 +++++++++++++++++++++++
 src/modules/calendar/e-cal-shell-content.c |  4 ++--
 2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/calendar/gui/e-comp-editor.c b/src/calendar/gui/e-comp-editor.c
index b7ad1aa889..d89b5ad131 100644
--- a/src/calendar/gui/e-comp-editor.c
+++ b/src/calendar/gui/e-comp-editor.c
@@ -2611,6 +2611,7 @@ e_comp_editor_fill_component (ECompEditor *comp_editor,
                              icalcomponent *component)
 {
        ECompEditorClass *comp_editor_class;
+       GtkWidget *focused_widget;
        gboolean is_valid;
 
        g_return_val_if_fail (E_IS_COMP_EDITOR (comp_editor), FALSE);
@@ -2620,8 +2621,30 @@ e_comp_editor_fill_component (ECompEditor *comp_editor,
        g_return_val_if_fail (comp_editor_class != NULL, FALSE);
        g_return_val_if_fail (comp_editor_class->fill_component != NULL, FALSE);
 
+       focused_widget = gtk_window_get_focus (GTK_WINDOW (comp_editor));
+       if (focused_widget) {
+               GtkWidget *parent, *ce_widget = GTK_WIDGET (comp_editor);
+
+               /* When a cell-renderer is focused and editing the cell content,
+                  then unfocus it may mean to free the currently focused widget,
+                  thus get the GtkTreeView in such cases. */
+               parent = focused_widget;
+               while (parent = gtk_widget_get_parent (parent), parent && parent != ce_widget) {
+                       if (GTK_IS_TREE_VIEW (parent)) {
+                               focused_widget = parent;
+                               break;
+                       }
+               }
+
+               /* Save any pending changes */
+               gtk_window_set_focus (GTK_WINDOW (comp_editor), NULL);
+       }
+
        is_valid = comp_editor_class->fill_component (comp_editor, component);
 
+       if (focused_widget)
+               gtk_window_set_focus (GTK_WINDOW (comp_editor), focused_widget);
+
        if (is_valid && comp_editor->priv->validation_alert) {
                e_alert_response (comp_editor->priv->validation_alert, GTK_RESPONSE_CLOSE);
                g_clear_object (&comp_editor->priv->validation_alert);
diff --git a/src/modules/calendar/e-cal-shell-content.c b/src/modules/calendar/e-cal-shell-content.c
index 25b876d6d8..966e570341 100644
--- a/src/modules/calendar/e-cal-shell-content.c
+++ b/src/modules/calendar/e-cal-shell-content.c
@@ -867,9 +867,9 @@ cal_shell_content_get_attendee_prop (icalcomponent *icalcomp,
        while (prop != NULL) {
                const gchar *attendee;
 
-               attendee = icalproperty_get_attendee (prop);
+               attendee = itip_strip_mailto (icalproperty_get_attendee (prop));
 
-               if (g_str_equal (itip_strip_mailto (attendee), address))
+               if (attendee && g_ascii_strcasecmp (attendee, address) == 0)
                        return prop;
 
                prop = icalcomponent_get_next_property (


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