Fix the crash when creating an event
package / package (push) Successful in 1m50s

02975fa3 took the sequence commits out of the event's setters, so that
saving could raise SEQUENCE only once. But EDS won't clone a component
with a raise pending, and the editor clones a new event as it opens it,
so creating an event aborted in e_cal_component_clone().

The setters commit the sequence again, as before. A GcalEvent now keeps
the SEQUENCE it was loaded with, and its clones carry it along, so
gcal_event_prepare_to_save() still raises an updated event's SEQUENCE
by one at most, and starts a new event at 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 09:52:50 -07:00
co-authored by Claude Opus 5.5
parent 02975fa3f5
commit ef57279413
4 changed files with 71 additions and 13 deletions
+26 -1
View File
@@ -837,6 +837,9 @@ event_prepare_to_save (void)
g_autoptr (GcalEvent) edited = NULL;
g_autoptr (GcalEvent) renamed = NULL;
g_autoptr (GcalEvent) created = NULL;
g_autoptr (GcalEvent) reclone = NULL;
g_autoptr (GcalEvent) unsequenced = NULL;
g_autoptr (GcalEvent) moved = NULL;
g_autoptr (GError) error = NULL;
gint64 before;
@@ -850,7 +853,6 @@ event_prepare_to_save (void)
move_event (edited, 1);
move_event (edited, 1);
move_event (edited, 1);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (edited)), ==, 3);
gcal_event_prepare_to_save (edited, FALSE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (edited)), ==, 4);
g_assert_cmpint (get_dtstamp_unix (edited), >=, before);
@@ -869,6 +871,29 @@ event_prepare_to_save (void)
gcal_event_prepare_to_save (created, TRUE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (created)), ==, 0);
g_assert_cmpint (get_dtstamp_unix (created), >=, before);
/*
* An event can be cloned right after its time changed, as when the editor
* opens a new event; EDS refuses to clone one with a raise pending. And a
* clone of a clone still counts from the SEQUENCE that was loaded.
*/
g_clear_object (&edited);
edited = gcal_event_new_from_event (original);
move_event (edited, 1);
reclone = gcal_event_new_from_event (edited);
g_assert_nonnull (reclone);
move_event (reclone, 1);
gcal_event_prepare_to_save (reclone, FALSE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (reclone)), ==, 4);
/* An event saved without a SEQUENCE has 0, so its first change makes 1 */
unsequenced = create_event_for_string (STUB_EVENT, &error);
g_assert_no_error (error);
moved = gcal_event_new_from_event (unsequenced);
move_event (moved, 1);
move_event (moved, 1);
gcal_event_prepare_to_save (moved, FALSE);
g_assert_cmpint (e_cal_component_get_sequence (gcal_event_get_component (moved)), ==, 1);
}
/*********************************************************************************************************************/