Closed Bug 325459 Opened 19 years ago Closed 19 years ago

monthview's relayout fails

Categories

(Calendar :: Internal Components, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Lightning 0.1

People

(Reporter: mvl, Unassigned)

References

Details

Attachments

(4 files, 2 obsolete files)

monthview's relayout does some math with durations, but that fails, due to a bug with adding negative durations.
And if it succeeds, it gets the wrong duration (34 days, that's not a multiple of 7)
And fixing that uncovers other bugs...
This patch fixes the duration part, but applying it will raise errors in the month view.
Attached patch patch for GetInSeconds — — Splinter Review
GetInSeconds is now aware of the is_neg-flag.
Attachment #210357 - Flags: first-review?(mvl)
Comment on attachment 210357 [details] [diff] [review]
patch for GetInSeconds

I can't review this yet, because those patches will break the monthview. It would be best to create one big patch out of those small patches that fixes everything.
(also, please don't use tabs)
Attachment #210357 - Flags: first-review?(mvl)
Attached patch full patch for calendar-month-view (obsolete) — — Splinter Review
dmose reviewed the initial checkin of this code.  This cleans up my mess (How did I write such bad code?).  The problems were mostly reference errors from moving reuseExistingGrid into a separate function.  Combined with the other patches on this bug, there needed to be a restructuring of the logic for when we can and cannot reuse the grid.  Before, we would get a 7 or -7 in the duration, now we need to check isNegative.  I also broke out some of the easier if() cases with returns, to avoid excessive indentation.  A patch -w will follow to make it clear what code actually changed.
Attached patch patch -w (obsolete) — — Splinter Review
patch -w for review.
Attachment #210427 - Flags: first-review?(dmose)
Comment on attachment 210427 [details] [diff] [review]
patch -w

bah... this still isn't right :-(  It doesn't reuse the grid when rows don't need to be added or subtracted.
Attachment #210427 - Attachment is obsolete: true
Attachment #210427 - Flags: first-review?(dmose)
I think that calculating the duration is wrong: it doesn't take the last day into account, because the last day is inclusive, not exclusive.
Patch fixes the previous issue of not re-using every time we actually could.  With this new version, we should reuse the grid every month (expect, of course, when the view is first loaded).
Attachment #210426 - Attachment is obsolete: true
Attached patch patch -w — — Splinter Review
updated patch -w for review
Attachment #210478 - Flags: first-review?(dmose)
(In reply to comment #7)
> I think that calculating the duration is wrong: it doesn't take the last day
> into account, because the last day is inclusive, not exclusive.
> 

The duration does come out at X weeks+6 days, but it comes out that way for both the old grid and the new start/end date, so it's ok.
Blocks: 324970
Blocks: 315051
Comment on attachment 210353 [details] [diff] [review]
partial patch, just fixes calDuration.cpp

r=dmose, but with a modified comment.  Two negatives cannot ever add together to become a positive.
Attachment #210353 - Flags: first-review+
Comment on attachment 210357 [details] [diff] [review]
patch for GetInSeconds

r=dmose
Attachment #210357 - Flags: first-review+
OS: Linux → All
Hardware: PC → All
Target Milestone: --- → Lightning 0.1
Comment on attachment 210478 [details] [diff] [review]
patch -w

Looks good; just a couple of nits:

> 
>           // If we've already drawn a view once, then in almost all cases we
>           // can resuse most of the grid.  We may need to add or subtract a row

Fix the "reuse" spelling as long as you're here?

>           // but this is still much faster than recreating all rows.
>           var canReuse = false;

This var can go away now, I think.

>+
>+          // OK, so we're off by one month.  We either need to add or subtract

s/month/week/, right?

>+          var gridrows = this.monthgridrows;
>+

Since this only gets referenced once, how about just accessing it directly rather than creating a temporary?

r=dmose with those addressed
Attachment #210478 - Flags: first-review?(dmose) → first-review+
Comment on attachment 210353 [details] [diff] [review]
partial patch, just fixes calDuration.cpp

>+    // Check if we need to add or substract. Remeber, two negatives
>+    // can add to something positive.
>+    if (idt.is_neg != mDuration.is_neg) {

A better comment:
    // Calculate the new absolute value of the duration
    // For two negative durations, the abs. value will increase,
    // so use + in that case.
    // Ofcourse, also use + when both durations are positive.
All patches checked in
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
The bugspam monkeys have struck again. They are currently chewing on default assignees for Calendar. Be afraid for your sanity!
Assignee: base → nobody
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: