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

Will Stephenson wstephenson at kde.org
Wed Feb 14 18:56:06 GMT 2007


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.

Will
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix_recurrence.diff
Type: text/x-diff
Size: 2060 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070214/b546699e/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testalarms.diff
Type: text/x-diff
Size: 7948 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070214/b546699e/attachment-0001.diff>
-------------- next part --------------
_______________________________________________
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