[Kde-pim] [PATCH] Fix RecurrenceRule::getNextDate()

David Jarvie lists at astrojar.org.uk
Wed Feb 14 23:55:49 GMT 2007


On Wednesday 14 February 2007 18:56:06 Will Stephenson wrote:
> https://bugzilla.novell.com/show_bug.cgi?id=200859 describes a bug where
> alarms go off before the start date of a recurring event.  I have been
> troubleshooting this and think I have a solution, but given the complexity
> of the recurrence code I would like some more eyes on it.
>
> The call stack that returns the invalid value looks like this:
> KCal::CalendarLocal::alarms()
> KCal::CalendarLocal::appendRecurringAlarms()
> Recurrence::getNextDateTime()
> RecurrenceRule::getNextDate()
>   m_duration is 0 so
> getNextValidDateInterval( preDate, recurrenceType() )
>
> and I think that that is where it falls down, as the next call
> (getDatesForInterval()) does not know about the start date.
>
> preDate is before the recurrence[rule]'s start date, so in
> getNextValidDateInterval() when the number of 'periods' that preDate is
> after startDate, we get a negative number, this negative number is added to
> startDate to get nextValid(Date) and the conditions are primed to get a
> wrong recurrence date.
>
> My fix is to clamp period at a minimum of 0.
>
> fix_recurrence.diff is the fix, testalarms.diff adds a rough and ready
> testcase that shows the bug in libkcal/tests.

I don't have time to look at it properly tonight (I'll do so tomorrow), but I 
tend to feel that the fix might be better applied further up the call chain. 
I think that in RecurrenceRule::getNextDate(), there could be a test near the 
beginning:

if ( preDate < startDt() )
  preDate = startDt().addSecs(-1);

I know that preDate is const, so this is really pseudo-code, but something 
equivalent might work.

There is probably no harm in applying your fix in case of other bugs, but I 
think that it can probably be caught before it gets there.

-- 
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/linux/kalarm.html
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/



More information about the kde-pim mailing list