After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 763015 - [year view] criticals on end of the month selection
[year view] criticals on end of the month selection
Status: RESOLVED FIXED
Product: gnome-calendar
Classification: Applications
Component: General
3.19.x
Other Linux
: Normal normal
: 3.26
Assigned To: GNOME Calendar maintainers
GNOME Calendar maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-03 00:26 UTC by Marinus Schraal
Modified: 2017-04-17 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
year view critical fix (1.91 KB, patch)
2016-03-03 00:26 UTC, Marinus Schraal
none Details | Review
year view critical fix (3.06 KB, patch)
2016-03-03 12:34 UTC, Marinus Schraal
accepted-commit_now Details | Review
multiday selection fix (2.58 KB, patch)
2016-03-06 13:21 UTC, Marinus Schraal
needs-work Details | Review
month-view: fix end-of-month multi-day selections (2.44 KB, patch)
2016-03-11 13:01 UTC, Marinus Schraal
none Details | Review
month-view: fix date adjust mishap (1.00 KB, patch)
2016-03-11 13:02 UTC, Marinus Schraal
none Details | Review
quick-add-popover: adjust end date properly (993 bytes, patch)
2016-03-11 13:02 UTC, Marinus Schraal
none Details | Review
month-view: fix end-of-month multi-day selections (1.81 KB, patch)
2016-03-13 11:59 UTC, Marinus Schraal
none Details | Review
month-view: fix end-of-month multi-day selections (1.73 KB, patch)
2016-03-13 12:00 UTC, Marinus Schraal
none Details | Review
year-view: criticals on last day of month events (2.64 KB, patch)
2016-03-13 15:43 UTC, Marinus Schraal
none Details | Review
month-view: fix end-of-month multi-day selections (1.37 KB, patch)
2016-03-13 15:43 UTC, Marinus Schraal
none Details | Review
month-view: fix date adjust mishap (1.00 KB, patch)
2016-03-13 15:43 UTC, Marinus Schraal
committed Details | Review
quick-add-popover: adjust end date properly (994 bytes, patch)
2016-03-13 15:44 UTC, Marinus Schraal
committed Details | Review
month-view: fix end-of-month multi-day selections (1.25 KB, patch)
2016-03-14 19:19 UTC, Marinus Schraal
none Details | Review
month-view: fix end-of-month multi-day selections (1.26 KB, patch)
2016-03-14 19:50 UTC, Marinus Schraal
committed Details | Review
year-view: criticals on last day of month events (1.88 KB, patch)
2016-03-14 19:54 UTC, Marinus Schraal
committed Details | Review

Description Marinus Schraal 2016-03-03 00:26:20 UTC
Created attachment 322924 [details] [review]
year view critical fix

I noticed when selecting the last day of the month with events on them resulting in some glib criticals on the console.

Turns out there's some code in the event sidebar relying on adding +1 to the day while creating a g_date_time, resulting in an invalid datetime for the last day of the month. Use g_date_time_add_days instead.
Comment 1 Marinus Schraal 2016-03-03 12:34:22 UTC
Created attachment 322970 [details] [review]
year view critical fix

Noticed this was done at a second spot as well. This one was only triggered when selecting a date range that ended at the last day of a month and then adding an event.
Comment 2 Marinus Schraal 2016-03-06 13:21:23 UTC
Created attachment 323194 [details] [review]
multiday selection fix

Noticed the same was happening for final-day-of-month multi-day events.
Comment 3 Georges Basile Stavracas Neto 2016-03-11 03:21:12 UTC
Review of attachment 322970 [details] [review]:

LGTM.
Comment 4 Georges Basile Stavracas Neto 2016-03-11 03:22:19 UTC
Review of attachment 323194 [details] [review]:

This patch does not apply cleanly on master. Also, I still see a issue when selecting a date range that ends in the last day of month (it shows me, e.g. April 00).
Comment 5 Marinus Schraal 2016-03-11 13:01:50 UTC
Created attachment 323700 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Also, fix the datetime comparison: anything above 0 indicates a
multi-day event.
Comment 6 Marinus Schraal 2016-03-11 13:02:28 UTC
Created attachment 323701 [details] [review]
month-view: fix date adjust mishap
Comment 7 Marinus Schraal 2016-03-11 13:02:57 UTC
Created attachment 323702 [details] [review]
quick-add-popover: adjust end date properly

Subtracting 1 from the first day of the month leads to an invalid date
being shown: use a proper function to adjust the date.
Comment 8 Marinus Schraal 2016-03-11 13:11:04 UTC
(In reply to Georges Basile Stavracas Neto from comment #4)
> Review of attachment 323194 [details] [review] [review]:
> 
> This patch does not apply cleanly on master. Also, I still see a issue when
> selecting a date range that ends in the last day of month (it shows me, e.g.
> April 00).

updated to head

Nice catch on the displayed day, it gets fixed in the attachment in comment #7 (note that the actual dates used for the event were ok).

Comment #6 contains another day adjustment fix, however this code (rebuild_popover_for_day) afaics never gets triggered and might need further cleanup.
Comment 9 Georges Basile Stavracas Neto 2016-03-11 14:15:53 UTC
Review of attachment 323700 [details] [review]:

Remove the extra line in quick-add-popover and it'll be OK.

::: src/gcal-quick-add-popover.c
@@ +386,3 @@
    * Everything else starts now and lasts 1 hour.
    */
+  all_day = datetime_compare_date (self->date_end, self->date_start) > 0;

The purpose of this line is that, when we select 1 day only, the event is created with the local time. Only if the user selects 2+ days, we consider the event all-day.
Comment 10 Georges Basile Stavracas Neto 2016-03-11 14:16:14 UTC
Review of attachment 323701 [details] [review]:

LGTM.
Comment 11 Georges Basile Stavracas Neto 2016-03-11 14:16:34 UTC
Review of attachment 323702 [details] [review]:

Nice catch, thanks.
Comment 12 Marinus Schraal 2016-03-13 11:59:12 UTC
Created attachment 323787 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Also, fix the datetime comparison: anything above 0 indicates a
multi-day event.
Comment 13 Marinus Schraal 2016-03-13 12:00:19 UTC
Created attachment 323788 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Comment 14 Georges Basile Stavracas Neto 2016-03-13 15:11:22 UTC
Review of attachment 323788 [details] [review]:

One more nitpick, probably the last one.

::: src/gcal-month-view.c
@@ +263,3 @@
   else
     {
+      GDateTime *start_dt, *tmp_dt, *end_dt;

Put the tmp_dt variable (and all the code related to it) inside the 'if (start != end)' condition. It is not used outside that context.
Comment 15 Georges Basile Stavracas Neto 2016-03-13 15:12:27 UTC
Review of attachment 323701 [details] [review]:

Just noticed a minor style issue. See below.

::: src/gcal-month-view.c
@@ +518,3 @@
                                   0, 0, 0);
 
+      dt_end = g_date_time_add_days(dt_start, 1);

Put a space between the function name and '('.
Comment 16 Georges Basile Stavracas Neto 2016-03-13 15:13:13 UTC
Review of attachment 323702 [details] [review]:

Another style issue.

::: src/gcal-quick-add-popover.c
@@ +233,2 @@
       if (dtend->is_date)
+        icaltime_adjust(dtend, -1, 0, 0, 0);

Put a space between the function name and '('.
Comment 17 Marinus Schraal 2016-03-13 15:43:06 UTC
Created attachment 323795 [details] [review]
year-view: criticals on last day of month events

Adding 1 to the day variable at the end of the month results in an
invalid datetime, use g_date_time_add_days instead.
Comment 18 Marinus Schraal 2016-03-13 15:43:24 UTC
Created attachment 323796 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Comment 19 Marinus Schraal 2016-03-13 15:43:51 UTC
Created attachment 323797 [details] [review]
month-view: fix date adjust mishap
Comment 20 Marinus Schraal 2016-03-13 15:44:06 UTC
Created attachment 323798 [details] [review]
quick-add-popover: adjust end date properly

Subtracting 1 from the first day of the month leads to an invalid date
being shown: use a proper function to adjust the date.
Comment 21 Georges Basile Stavracas Neto 2016-03-14 19:08:47 UTC
Review of attachment 323796 [details] [review]:

A minor nitpick.

::: src/gcal-month-view.c
@@ +281,2 @@
       /* Only setup an end date when days are different */
+      if (start_day != end_day) {

Use the GNU C style for the curly braces.
Comment 22 Georges Basile Stavracas Neto 2016-03-14 19:09:11 UTC
Review of attachment 323797 [details] [review]:

LGTM.
Comment 23 Georges Basile Stavracas Neto 2016-03-14 19:13:00 UTC
Review of attachment 323798 [details] [review]:

LGTM.
Comment 24 Georges Basile Stavracas Neto 2016-03-14 19:16:21 UTC
Review of attachment 323795 [details] [review]:

Looks good, but can be simplified.

::: src/gcal-year-view.c
@@ +290,3 @@
+                              g_date_time_get_month (date),
+                              g_date_time_get_day_of_month (date),
+                              0, 0, 0);

The tmp_date is not needed here. Use 'second_date = g_date_time_add_days (date, 1)' directly.

@@ +1064,2 @@
       start_date = g_date_time_new_local (dtstart->year, dtstart->month, dtstart->day, 0, 0, 0);
+      tmp_date = g_date_time_new_local (dtend->year, dtend->month, dtend->day, 0, 0, 0);

The tmp_date var is not needed here. Use end_date directly.
Comment 25 Marinus Schraal 2016-03-14 19:19:49 UTC
Created attachment 323909 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Comment 26 Georges Basile Stavracas Neto 2016-03-14 19:28:27 UTC
Review of attachment 323909 [details] [review]:

Another nitpick.

::: src/gcal-month-view.c
@@ +287,3 @@
+        end_dt = g_date_time_add_days (tmp_dt, 1);
+
+        g_clear_pointer (&tmp_dt, g_date_time_unref);

Fix code alignment inside the 'if' condition.
Comment 27 Marinus Schraal 2016-03-14 19:50:17 UTC
Created attachment 323913 [details] [review]
month-view: fix end-of-month multi-day selections

Use g_date_time_add_days to add a day to the final day of the month to
fix behaviour when selecting a range up to the last day of the month.
Comment 28 Marinus Schraal 2016-03-14 19:54:16 UTC
Created attachment 323914 [details] [review]
year-view: criticals on last day of month events

Adding 1 to the day variable at the end of the month results in an
invalid datetime, use g_date_time_add_days instead.
Comment 29 Georges Basile Stavracas Neto 2016-03-14 19:57:47 UTC
Thanks for your hard work on this bug.

Attachment 323797 [details] pushed as c67d520 - month-view: fix date adjust mishap
Attachment 323798 [details] pushed as 2ac228a - quick-add-popover: adjust end date properly
Attachment 323913 [details] pushed as 96d2b37 - month-view: fix end-of-month multi-day selections
Attachment 323914 [details] pushed as 465d786 - year-view: criticals on last day of month events