Fix bug 435166 - better error handling for repeating tasks without start date [NS_ERROR_INVALID_POINTER in calRecurrenceInfo.js]. r=dbo
authorgekacheka@yahoo.com
Thu, 02 Oct 2008 15:00:53 +0200
changeset 482 afdbefbf1c385359baf889cbb437e31fa626c7d0
parent 481 b47711026af10f0bc2d21085fd80c79336fb550d
child 483 d622a1f964c4205435eeb8544b8013342de4465d
push idunknown
push userunknown
push dateunknown
reviewersdbo
bugs435166
Fix bug 435166 - better error handling for repeating tasks without start date [NS_ERROR_INVALID_POINTER in calRecurrenceInfo.js]. r=dbo
calendar/base/content/calendar-task-view.js
calendar/base/src/calRecurrenceInfo.js
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -134,19 +134,20 @@ var taskDetailsView = {
             }
             document.getElementById("task-start-row").Item = item;
             document.getElementById("task-due-row").Item = item;
             var parentItem = item;
             if (parentItem.parentItem != parentItem) {
                 parentItem = parentItem.parentItem;
             }
             var recurrenceInfo = parentItem.recurrenceInfo;
-            if (displayElement("calendar-task-details-repeat-row", recurrenceInfo != null)) {
+            var recurStart = parentItem.recurrenceStartDate;
+            if (displayElement("calendar-task-details-repeat-row", recurrenceInfo && recurStart)) {
                 var kDefaultTimezone = calendarDefaultTimezone();
-                var startDate = item.entryDate ? item.entryDate.getInTimezone(kDefaultTimezone) : null;
+                var startDate = recurStart.getInTimezone(kDefaultTimezone);
                 var endDate = item.dueDate ? item.dueDate.getInTimezone(kDefaultTimezone) : null;
                 var detailsString = recurrenceRule2String(recurrenceInfo,startDate,endDate,startDate.isDate);
                 if (detailsString) {
                     document.getElementById("calendar-task-details-repeat").value = detailsString.split("\n").join(" ");
                 }
             }
             var textbox = document.getElementById("calendar-task-details-description");
             var description = item.hasProperty("DESCRIPTION") ? item.getProperty("DESCRIPTION") : null;
--- a/calendar/base/src/calRecurrenceInfo.js
+++ b/calendar/base/src/calRecurrenceInfo.js
@@ -482,16 +482,23 @@ calRecurrenceInfo.prototype = {
         var baseDuration = this.mBaseItem.duration;
         if (baseDuration) {
             var duration = baseDuration.clone();
             duration.isNegative = true;
             searchStart.addDuration(duration);
         }
 
         var startDate = this.mBaseItem.recurrenceStartDate;
+        if (startDate == null) {
+            // Todo created by other apps may have a saved recurrence but
+            // start and due dates disabled.  Since no recurrenceStartDate,
+            // treat as undated task.
+            return [];
+        }
+
         var dates = [];
 
         // toss in exceptions first. Save a map of all exceptions ids, so we
         // don't add the wrong occurrences later on.
         var occurrenceMap = {};
         for (var ex in this.mExceptionMap) {
             var item = this.mExceptionMap[ex];
             var occDate = checkIfInRange(item, aRangeStart, aRangeEnd, true);