From: Art Cancro Date: Fri, 14 Mar 2003 04:21:57 +0000 (+0000) Subject: * clone events to be encapsulated before saving, because the original X-Git-Tag: v7.86~5973 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=e468938adea84a8b66b75166c27776bc973ccac0 * clone events to be encapsulated before saving, because the original instance may already have a parent, and that makes crashy crashy --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index 3ea57ecf7..a3deecacc 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 410.4 2003/03/14 04:21:57 ajc +* clone events to be encapsulated before saving, because the original + instance may already have a parent, and that makes crashy crashy + Revision 410.3 2003/03/13 05:57:17 ajc * More encapsulation. Warning: there are bugs in this!! @@ -1288,4 +1292,3 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix - diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index 74e19970d..f832bb5b0 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -252,7 +252,6 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) { } /* Encapsulate the VEVENT component into a complete VCALENDAR */ - lprintf(9, "Creating new calendar component\n"); encaps = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); if (encaps == NULL) { lprintf(3, "Error at %s:%d - could not allocate component!\n", @@ -268,24 +267,14 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) { /* Encapsulate the subcomponent inside */ lprintf(9, "Doing the encapsulation\n"); - - lprintf(9, "Here's what we've got so far:\n-----%s\n-----\n", - icalcomponent_as_ical_string(encaps) - ); - lprintf(9, "Here's what we want to insert:\n-----%s\n-----\n", - icalcomponent_as_ical_string(subcomp) - ); - icalcomponent_add_component(encaps, subcomp); /* Convert all timestamps to UTC so we don't have to deal with * stupid VTIMEZONE crap. */ - lprintf(9, "Dezonifying it all\n"); ical_dezonify(encaps); /* Return the object we just created. */ - lprintf(9, "...done!\n"); return(encaps); } diff --git a/webcit/event.c b/webcit/event.c index ef21f0fe9..dc89fd2d5 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -651,10 +651,14 @@ STARTOVER: lprintf(9, "Remove unlisted attendees\n"); } /* - * Serialize it and save it to the message base + * Serialize it and save it to the message base. We clone it first, + * for two reasons: one, it's easier to just free the whole thing + * when we're done instead of unbundling, but more importantly, we + * can't encapsulate something that may already be encapsulated + * somewhere else. */ lprintf(9, "Encapsulating into full VCALENDAR component\n"); - encaps = ical_encapsulate_subcomponent(vevent); + encaps = ical_encapsulate_subcomponent(icalcomponent_new_clone(vevent)); lprintf(9, "Serializing it for saving\n"); if (encaps != NULL) { serv_puts("ENT0 1|||4"); @@ -665,10 +669,7 @@ STARTOVER: lprintf(9, "Remove unlisted attendees\n"); serv_puts(icalcomponent_as_ical_string(encaps)); serv_puts("000"); } - if (encaps != vevent) { - icalcomponent_remove_component(encaps, vevent); - icalcomponent_free(encaps); - } + icalcomponent_free(encaps); } }