Blame SOURCES/evolution-3.28.5-crash-empty-attendee.patch

5d780a
diff -up evolution-3.28.5/src/calendar/gui/e-comp-editor.c.crash-empty-attendee evolution-3.28.5/src/calendar/gui/e-comp-editor.c
5d780a
--- evolution-3.28.5/src/calendar/gui/e-comp-editor.c.crash-empty-attendee	2018-07-30 15:37:05.000000000 +0200
06ab03
+++ evolution-3.28.5/src/calendar/gui/e-comp-editor.c	2020-05-15 12:24:47.067773299 +0200
06ab03
@@ -112,10 +112,10 @@ ece_restore_focus (ECompEditor *comp_edi
06ab03
 	g_return_if_fail (E_IS_COMP_EDITOR (comp_editor));
06ab03
 
06ab03
 	if (comp_editor->priv->restore_focus) {
06ab03
-		gtk_widget_grab_focus (comp_editor->priv->restore_focus);
06ab03
-
06ab03
 		if (GTK_IS_ENTRY (comp_editor->priv->restore_focus))
06ab03
-			gtk_editable_set_position (GTK_EDITABLE (comp_editor->priv->restore_focus), 0);
06ab03
+			gtk_entry_grab_focus_without_selecting (GTK_ENTRY (comp_editor->priv->restore_focus));
06ab03
+		else
06ab03
+			gtk_widget_grab_focus (comp_editor->priv->restore_focus);
06ab03
 
06ab03
 		comp_editor->priv->restore_focus = NULL;
06ab03
 	}
5d780a
@@ -2610,6 +2610,7 @@ e_comp_editor_fill_component (ECompEdito
5d780a
 			      icalcomponent *component)
5d780a
 {
5d780a
 	ECompEditorClass *comp_editor_class;
5d780a
+	GtkWidget *focused_widget;
5d780a
 	gboolean is_valid;
5d780a
 
5d780a
 	g_return_val_if_fail (E_IS_COMP_EDITOR (comp_editor), FALSE);
06ab03
@@ -2619,8 +2620,34 @@ e_comp_editor_fill_component (ECompEdito
5d780a
 	g_return_val_if_fail (comp_editor_class != NULL, FALSE);
5d780a
 	g_return_val_if_fail (comp_editor_class->fill_component != NULL, FALSE);
5d780a
 
5d780a
+	focused_widget = gtk_window_get_focus (GTK_WINDOW (comp_editor));
5d780a
+	if (focused_widget) {
5d780a
+		GtkWidget *parent, *ce_widget = GTK_WIDGET (comp_editor);
5d780a
+
5d780a
+		/* When a cell-renderer is focused and editing the cell content,
5d780a
+		   then unfocus it may mean to free the currently focused widget,
5d780a
+		   thus get the GtkTreeView in such cases. */
5d780a
+		parent = focused_widget;
5d780a
+		while (parent = gtk_widget_get_parent (parent), parent && parent != ce_widget) {
5d780a
+			if (GTK_IS_TREE_VIEW (parent)) {
5d780a
+				focused_widget = parent;
5d780a
+				break;
5d780a
+			}
5d780a
+		}
5d780a
+
5d780a
+		/* Save any pending changes */
5d780a
+		gtk_window_set_focus (GTK_WINDOW (comp_editor), NULL);
5d780a
+	}
5d780a
+
5d780a
 	is_valid = comp_editor_class->fill_component (comp_editor, component);
5d780a
 
06ab03
+	if (focused_widget) {
06ab03
+		if (GTK_IS_ENTRY (focused_widget))
06ab03
+			gtk_entry_grab_focus_without_selecting (GTK_ENTRY (focused_widget));
06ab03
+		else
06ab03
+			gtk_widget_grab_focus (focused_widget);
06ab03
+	}
5d780a
+
5d780a
 	if (is_valid && comp_editor->priv->validation_alert) {
5d780a
 		e_alert_response (comp_editor->priv->validation_alert, GTK_RESPONSE_CLOSE);
5d780a
 		g_clear_object (&comp_editor->priv->validation_alert);
06ab03
diff -up evolution-3.28.5/src/calendar/gui/e-comp-editor-event.c.crash-empty-attendee evolution-3.28.5/src/calendar/gui/e-comp-editor-event.c
06ab03
--- evolution-3.28.5/src/calendar/gui/e-comp-editor-event.c.crash-empty-attendee	2020-05-15 12:23:49.488776711 +0200
06ab03
+++ evolution-3.28.5/src/calendar/gui/e-comp-editor-event.c	2020-05-15 12:24:47.064773299 +0200
06ab03
@@ -67,14 +67,14 @@ ece_event_update_times (ECompEditorEvent
06ab03
 			EDateEdit *date_edit,
06ab03
 			gboolean change_end_datetime)
06ab03
 {
06ab03
-	GtkWidget *widget;
06ab03
 	guint flags;
06ab03
 
06ab03
 	g_return_if_fail (E_IS_COMP_EDITOR_EVENT (event_editor));
06ab03
 	g_return_if_fail (E_IS_DATE_EDIT (date_edit));
06ab03
 
06ab03
-	widget = e_date_edit_get_entry (date_edit);
06ab03
-	if (widget && gtk_widget_has_focus (widget))
06ab03
+	if (e_date_edit_has_focus (date_edit) ||
06ab03
+	    !e_date_edit_date_is_valid (date_edit) ||
06ab03
+	    !e_date_edit_time_is_valid (date_edit))
06ab03
 		return;
06ab03
 
06ab03
 	if (!e_comp_editor_get_updating (E_COMP_EDITOR (event_editor))) {
06ab03
diff -up evolution-3.28.5/src/calendar/gui/e-comp-editor-property-part.c.crash-empty-attendee evolution-3.28.5/src/calendar/gui/e-comp-editor-property-part.c
06ab03
--- evolution-3.28.5/src/calendar/gui/e-comp-editor-property-part.c.crash-empty-attendee	2020-05-15 12:24:06.520775702 +0200
06ab03
+++ evolution-3.28.5/src/calendar/gui/e-comp-editor-property-part.c	2020-05-15 12:30:44.589752111 +0200
06ab03
@@ -589,6 +589,23 @@ struct _ECompEditorPropertyPartDatetimeP
06ab03
 G_DEFINE_ABSTRACT_TYPE (ECompEditorPropertyPartDatetime, e_comp_editor_property_part_datetime, E_TYPE_COMP_EDITOR_PROPERTY_PART)
06ab03
 
06ab03
 static void
06ab03
+ecepp_datetime_changed_cb (ECompEditorPropertyPart *property_part)
06ab03
+{
06ab03
+	GtkWidget *edit_widget;
06ab03
+
06ab03
+	g_return_if_fail (E_IS_COMP_EDITOR_PROPERTY_PART_DATETIME (property_part));
06ab03
+
06ab03
+	edit_widget = e_comp_editor_property_part_get_edit_widget (property_part);
06ab03
+
06ab03
+	if (!edit_widget || e_date_edit_has_focus (E_DATE_EDIT (edit_widget)) ||
06ab03
+	    !e_date_edit_date_is_valid (E_DATE_EDIT (edit_widget)) ||
06ab03
+	    !e_date_edit_time_is_valid (E_DATE_EDIT (edit_widget)))
06ab03
+		return;
06ab03
+
06ab03
+	e_comp_editor_property_part_emit_changed (property_part);
06ab03
+}
06ab03
+
06ab03
+static void
06ab03
 ecepp_datetime_create_widgets (ECompEditorPropertyPart *property_part,
06ab03
 			       GtkWidget **out_label_widget,
06ab03
 			       GtkWidget **out_edit_widget)
06ab03
@@ -616,9 +633,9 @@ ecepp_datetime_create_widgets (ECompEdit
06ab03
 	gtk_widget_show (*out_edit_widget);
06ab03
 
06ab03
 	g_signal_connect_swapped (*out_edit_widget, "changed",
06ab03
-		G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
06ab03
+		G_CALLBACK (ecepp_datetime_changed_cb), property_part);
06ab03
 	g_signal_connect_swapped (*out_edit_widget, "notify::show-time",
06ab03
-		G_CALLBACK (e_comp_editor_property_part_emit_changed), property_part);
06ab03
+		G_CALLBACK (ecepp_datetime_changed_cb), property_part);
06ab03
 }
06ab03
 
06ab03
 static void
06ab03
diff -up evolution-3.28.5/src/e-util/e-dateedit.c.crash-empty-attendee evolution-3.28.5/src/e-util/e-dateedit.c
06ab03
--- evolution-3.28.5/src/e-util/e-dateedit.c.crash-empty-attendee	2020-05-15 12:22:47.352780394 +0200
06ab03
+++ evolution-3.28.5/src/e-util/e-dateedit.c	2020-05-15 12:24:47.068773299 +0200
06ab03
@@ -527,6 +527,13 @@ e_date_edit_new (void)
06ab03
 }
06ab03
 
06ab03
 static void
06ab03
+on_time_entry_changed_cb (GtkEditable *editable,
06ab03
+			  EDateEdit *dedit)
06ab03
+{
06ab03
+	e_date_edit_check_time_changed (dedit);
06ab03
+}
06ab03
+
06ab03
+static void
06ab03
 create_children (EDateEdit *dedit)
06ab03
 {
06ab03
 	EDateEditPrivate *priv;
06ab03
@@ -636,6 +643,9 @@ create_children (EDateEdit *dedit)
06ab03
 	g_signal_connect_after (
06ab03
 		child, "focus_out_event",
06ab03
 		G_CALLBACK (on_time_entry_focus_out), dedit);
06ab03
+	g_signal_connect (
06ab03
+		child, "changed",
06ab03
+		G_CALLBACK (on_time_entry_changed_cb), dedit);
06ab03
 	g_signal_connect_after (
06ab03
 		priv->time_combo, "changed",
06ab03
 		G_CALLBACK (on_date_edit_time_selected), dedit);
06ab03
@@ -2000,7 +2010,6 @@ on_date_entry_focus_out (GtkEntry *entry
06ab03
                          EDateEdit *dedit)
06ab03
 {
06ab03
 	struct tm tmp_tm;
06ab03
-	GtkWidget *msg_dialog;
06ab03
 
06ab03
 	tmp_tm.tm_year = 0;
06ab03
 	tmp_tm.tm_mon = 0;
06ab03
@@ -2009,21 +2018,9 @@ on_date_entry_focus_out (GtkEntry *entry
06ab03
 	e_date_edit_check_date_changed (dedit);
06ab03
 
06ab03
 	if (!e_date_edit_date_is_valid (dedit)) {
06ab03
-		msg_dialog = gtk_message_dialog_new (
06ab03
-			NULL,
06ab03
-			GTK_DIALOG_MODAL,
06ab03
-			GTK_MESSAGE_WARNING,
06ab03
-			GTK_BUTTONS_OK,
06ab03
-			"%s", _("Invalid Date Value"));
06ab03
-		gtk_dialog_run (GTK_DIALOG (msg_dialog));
06ab03
-		gtk_widget_destroy (msg_dialog);
06ab03
-		e_date_edit_get_date (
06ab03
-			dedit, &tmp_tm.tm_year,
06ab03
-			&tmp_tm.tm_mon, &tmp_tm.tm_mday);
06ab03
-		e_date_edit_set_date (
06ab03
-			dedit, tmp_tm.tm_year,
06ab03
-			tmp_tm.tm_mon, tmp_tm.tm_mday);
06ab03
-		gtk_widget_grab_focus (GTK_WIDGET (entry));
06ab03
+		gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
06ab03
+		gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Invalid Date Value"));
06ab03
+		gtk_entry_grab_focus_without_selecting (entry);
06ab03
 		return FALSE;
06ab03
 	} else if (e_date_edit_get_date (
06ab03
 		dedit, &tmp_tm.tm_year, &tmp_tm.tm_mon, &tmp_tm.tm_mday)) {
06ab03
@@ -2041,6 +2038,10 @@ on_date_entry_focus_out (GtkEntry *entry
06ab03
 		dedit->priv->date_set_to_none = TRUE;
06ab03
 		e_date_edit_update_date_entry (dedit);
06ab03
 	}
06ab03
+
06ab03
+	gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
06ab03
+	gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
06ab03
+
06ab03
 	return FALSE;
06ab03
 }
06ab03
 
06ab03
@@ -2049,23 +2050,17 @@ on_time_entry_focus_out (GtkEntry *entry
06ab03
                          GdkEventFocus *event,
06ab03
                          EDateEdit *dedit)
06ab03
 {
06ab03
-	GtkWidget *msg_dialog;
06ab03
-
06ab03
 	e_date_edit_check_time_changed (dedit);
06ab03
 
06ab03
 	if (!e_date_edit_time_is_valid (dedit)) {
06ab03
-		msg_dialog = gtk_message_dialog_new (
06ab03
-			NULL,
06ab03
-			GTK_DIALOG_MODAL,
06ab03
-			GTK_MESSAGE_WARNING,
06ab03
-			GTK_BUTTONS_OK,
06ab03
-			"%s", _("Invalid Time Value"));
06ab03
-		gtk_dialog_run (GTK_DIALOG (msg_dialog));
06ab03
-		gtk_widget_destroy (msg_dialog);
06ab03
-		e_date_edit_set_time (dedit,e_date_edit_get_time (dedit));
06ab03
-		gtk_widget_grab_focus (GTK_WIDGET (entry));
06ab03
-		return FALSE;
06ab03
+		gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, "dialog-warning");
06ab03
+		gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, _("Invalid Time Value"));
06ab03
+		gtk_entry_grab_focus_without_selecting (entry);
06ab03
+	} else {
06ab03
+		gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
06ab03
+		gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
06ab03
 	}
06ab03
+
06ab03
 	return FALSE;
06ab03
 }
06ab03
 
06ab03
@@ -2363,7 +2358,7 @@ e_date_edit_check_time_changed (EDateEdi
06ab03
 		tmp_tm.tm_min);
06ab03
 
06ab03
 	if (time_changed) {
06ab03
-		e_date_edit_update_time_entry (dedit);
06ab03
+		/* Do not call e_date_edit_update_time_entry (dedit); let the user correct the value */
06ab03
 		g_signal_emit (dedit, signals[CHANGED], 0);
06ab03
 	}
06ab03
 }
06ab03
@@ -2467,6 +2462,20 @@ e_date_edit_set_date_internal (EDateEdit
06ab03
 		}
06ab03
 	}
06ab03
 
06ab03
+	if (date_changed) {
06ab03
+		GtkEntry *entry;
06ab03
+
06ab03
+		entry = GTK_ENTRY (dedit->priv->date_entry);
06ab03
+
06ab03
+		if (priv->date_is_valid) {
06ab03
+			gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
06ab03
+			gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
06ab03
+		} else {
06ab03
+			gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "dialog-warning");
06ab03
+			gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_SECONDARY, _("Invalid Date Value"));
06ab03
+		}
06ab03
+	}
06ab03
+
06ab03
 	return date_changed;
06ab03
 }
06ab03
 
06ab03
@@ -2510,6 +2519,20 @@ e_date_edit_set_time_internal (EDateEdit
06ab03
 		}
06ab03
 	}
06ab03
 
06ab03
+	if (time_changed) {
06ab03
+		GtkEntry *entry;
06ab03
+
06ab03
+		entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dedit->priv->time_combo)));
06ab03
+
06ab03
+		if (priv->time_is_valid) {
06ab03
+			gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
06ab03
+			gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, NULL);
06ab03
+		} else {
06ab03
+			gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_PRIMARY, "dialog-warning");
06ab03
+			gtk_entry_set_icon_tooltip_text (entry, GTK_ENTRY_ICON_PRIMARY, _("Invalid Time Value"));
06ab03
+		}
06ab03
+	}
06ab03
+
06ab03
 	return time_changed;
06ab03
 }
06ab03
 
06ab03
@@ -2561,3 +2584,13 @@ e_date_edit_get_entry (EDateEdit *dedit)
06ab03
 
06ab03
 	return GTK_WIDGET (dedit->priv->date_entry);
06ab03
 }
06ab03
+
06ab03
+gboolean
06ab03
+e_date_edit_has_focus (EDateEdit *dedit)
06ab03
+{
06ab03
+	g_return_val_if_fail (E_IS_DATE_EDIT (dedit), FALSE);
06ab03
+
06ab03
+	return gtk_widget_has_focus (GTK_WIDGET (dedit)) ||
06ab03
+		(dedit->priv->date_entry && gtk_widget_has_focus (dedit->priv->date_entry)) ||
06ab03
+		(dedit->priv->time_combo && gtk_widget_has_focus (dedit->priv->time_combo));
06ab03
+}
06ab03
diff -up evolution-3.28.5/src/e-util/e-dateedit.h.crash-empty-attendee evolution-3.28.5/src/e-util/e-dateedit.h
06ab03
--- evolution-3.28.5/src/e-util/e-dateedit.h.crash-empty-attendee	2020-05-15 12:24:41.256773643 +0200
06ab03
+++ evolution-3.28.5/src/e-util/e-dateedit.h	2020-05-15 12:24:47.068773299 +0200
06ab03
@@ -211,6 +211,8 @@ void		e_date_edit_set_get_time_callback
06ab03
 
06ab03
 GtkWidget *	e_date_edit_get_entry		(EDateEdit *dedit);
06ab03
 
06ab03
+gboolean	e_date_edit_has_focus		(EDateEdit *dedit);
06ab03
+
06ab03
 G_END_DECLS
06ab03
 
06ab03
 #endif /* E_DATE_EDIT_H */
5d780a
diff -up evolution-3.28.5/src/modules/calendar/e-cal-shell-content.c.crash-empty-attendee evolution-3.28.5/src/modules/calendar/e-cal-shell-content.c
5d780a
--- evolution-3.28.5/src/modules/calendar/e-cal-shell-content.c.crash-empty-attendee	2018-07-30 15:37:05.000000000 +0200
06ab03
+++ evolution-3.28.5/src/modules/calendar/e-cal-shell-content.c	2020-05-15 12:21:11.487786075 +0200
5d780a
@@ -847,9 +847,9 @@ cal_shell_content_get_attendee_prop (ica
5d780a
 	while (prop != NULL) {
5d780a
 		const gchar *attendee;
5d780a
 
5d780a
-		attendee = icalproperty_get_attendee (prop);
5d780a
+		attendee = itip_strip_mailto (icalproperty_get_attendee (prop));
5d780a
 
5d780a
-		if (g_str_equal (itip_strip_mailto (attendee), address))
5d780a
+		if (attendee && g_ascii_strcasecmp (attendee, address) == 0)
5d780a
 			return prop;
5d780a
 
5d780a
 		prop = icalcomponent_get_next_property (