ubuntu-touch-coreapps-reviewers team mailing list archive
-
ubuntu-touch-coreapps-reviewers team
-
Mailing list archive
-
Message #09370
[Merge] lp:~renatofilho/ubuntu-calendar-app/handle-events-with-invalid-date into lp:ubuntu-calendar-app
Renato Araujo Oliveira Filho has proposed merging lp:~renatofilho/ubuntu-calendar-app/handle-events-with-invalid-date into lp:ubuntu-calendar-app.
Commit message:
Make sure the app does not crash or freeze if an event contains invalid start/end time.
Requested reviews:
Ubuntu Calendar Developers (ubuntu-calendar-dev)
For more details, see:
https://code.launchpad.net/~renatofilho/ubuntu-calendar-app/handle-events-with-invalid-date/+merge/293169
--
Your team Ubuntu Calendar Developers is requested to review the proposed merge of lp:~renatofilho/ubuntu-calendar-app/handle-events-with-invalid-date into lp:ubuntu-calendar-app.
=== modified file 'TimeLineBase.qml'
--- TimeLineBase.qml 2016-03-21 21:28:31 +0000
+++ TimeLineBase.qml 2016-04-27 20:03:38 +0000
@@ -85,35 +85,6 @@
var events = messageObject.reply
var dirty = false
for (var i=0; i < events.length; i++) {
- var e = intern.eventsById[events[i].eventId]
- if (e.eventId != events[i].itemId) {
- console.warn("Event does not match id:", i)
- dirty = true
- }
- if (e.startDateTime.getTime() != events[i].eventStartTime) {
- console.warn("Event does not match start time")
- dirty = true
- }
- if (isNaN(e.endDateTime.getTime())) {
- if (events[i].eventEndTime != events[i].eventStartTime) {
- // Events with same start and end time have empty end date
- console.warn("Event does not match end time")
- dirty = true
- }
- } else if (e.endDateTime.getTime() != events[i].eventEndTime) {
- if ((e.endDateTime.getTime() - events[i].eventEndTime) > 3600000) {
- // Events with same start and end time have lenght equal to 20 minutes
- console.warn("Event does not match end time")
- dirty = true
- }
- }
-
- if (dirty) {
- console.warn("Mark as dirty")
- intern.dirty = true
- break
- }
-
createVisual(events[i])
}
}
=== modified file 'calendar_canvas.js'
--- calendar_canvas.js 2016-04-05 14:44:37 +0000
+++ calendar_canvas.js 2016-04-27 20:03:38 +0000
@@ -3,6 +3,11 @@
function minutesSince(since, until)
{
+ if (isNaN(until.getTime())) {
+ console.debug("Invalid until time:" + until)
+ return 0
+ }
+
var sinceTime = new Date(since)
sinceTime.setSeconds(0)
var untilTime = new Date(until)
@@ -39,14 +44,16 @@
var eventStartTimeInMinutes = minutesSince(date, event.startDateTime)
var eventEndTimeInMinutes = minutesSince(date, isNaN(event.endDateTime.getTime()) ? event.startDateTime : event.endDateTime)
+ var startDateTime = isNaN(event.startDateTime.getTime()) ? date.getTime() : event.startDateTime.getTime()
+ var endDateTime = isNaN(event.endDateTime.getTime()) ? startDateTime : event.endDateTime.getTime()
// avoid to draw events too small
if ((eventEndTimeInMinutes - eventStartTimeInMinutes) < 20)
eventEndTimeInMinutes = eventStartTimeInMinutes + 20
eventsInfo.push({'eventId': event.itemId,
- 'eventStartTime': event.startDateTime.getTime(),
- 'eventEndTime': isNaN(event.endDateTime.getTime()) ? event.startDateTime.getTime() : event.endDateTime.getTime(),
+ 'eventStartTime': startDateTime,
+ 'eventEndTime': endDateTime,
'startTime': eventStartTimeInMinutes,
'endTime': eventEndTimeInMinutes,
'endTimeInSecs': event.endDateTime.getTime(),
References