Closed Bug 1012860 Opened 10 years ago Closed 10 years ago

MSVC build warning: WidgetUtils.cpp(22) : warning C4305: 'argument' : truncation from 'double' to 'mozilla::gfx::Float'

Categories

(Core :: Widget, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: dholbert, Assigned: dholbert)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 2 obsolete files)

Our TBPL Windows builds currently hit these build warnings:
{
c:\builds\moz2_slave\try-w32-d-00000000000000000000\build\widget\xpwidgets\WidgetUtils.cpp(22) : warning C4305: 'argument' : truncation from 'double' to 'mozilla::gfx::Float'
c:\builds\moz2_slave\try-w32-d-00000000000000000000\build\widget\xpwidgets\WidgetUtils.cpp(26) : warning C4305: 'argument' : truncation from 'double' to 'mozilla::gfx::Float'
c:\builds\moz2_slave\try-w32-d-00000000000000000000\build\widget\xpwidgets\WidgetUtils.cpp(30) : warning C4305: 'argument' : truncation from 'double' to 'mozilla::gfx::Float'
}

I believe these are from passing M_PI (a #define for pi, implicitly a double) in to a function that accepts a gfx::Float (a float).

Filing this bug to fix these (by making the conversion explicit with static_cast.)
Attached patch fix v1 (obsolete) — Splinter Review
Haven't tested this on Windows yet, but I expect this should fix the problem. Will request review after I've confirmed that.
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attached patch fix v2 (obsolete) — Splinter Review
(just fixing a whitespace issue from earlier patch)
Attachment #8425055 - Attachment is obsolete: true
Attached patch fix v3Splinter Review
Hooray -- the Try run is green, and 'grep' confirms that there are no warnings for xpwidgets in the log.

I'm posting this new version of the patch to fix the bug # in commit message (I copypasted the wrong bug # into the last one), and requesting review.
Attachment #8425056 - Attachment is obsolete: true
Attachment #8425088 - Flags: review?(roc)
For the record, the Try run with this is: https://tbpl.mozilla.org/?tree=Try&rev=b3276cad96e9

(This bug's patch is the middle cset there -- mistakenly labeled in the commit message as being for bug 1012858)
Comment on attachment 8425088 [details] [diff] [review]
fix v3

Review of attachment 8425088 [details] [diff] [review]:
-----------------------------------------------------------------

::: widget/xpwidgets/WidgetUtils.cpp
@@ +13,5 @@
>  ComputeTransformForRotation(const nsIntRect& aBounds,
>                                ScreenRotation aRotation)
>  {
>      gfx::Matrix transform;
> +    static gfx::Float floatPi = static_cast<gfx::Float>(M_PI);

static const
Attachment #8425088 - Flags: review?(roc) → review+
Will add 'const' before landing. Thanks!
https://hg.mozilla.org/mozilla-central/rev/2940750f68ea
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: