Closed Bug 776902 Opened 10 years ago Closed 10 years ago

nsFilePicker nullptr related build error with vc11

Categories

(Core :: Widget: Win32, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: jimm, Unassigned)

References

Details

Attachments

(1 file)

nsFilePicker.cpp
f:/Mozilla/firefox/mc/widget/windows/nsFilePicker.cpp(542) : error C2440: '=' : cannot convert from 'nullptr' to 'int'
        A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
f:/Mozilla/firefox/mc/widget/windows/nsFilePicker.cpp(551) : error C2440: '=' : cannot convert from 'nullptr' to 'LPARAM'
        A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
f:/Mozilla/firefox/mc/widget/windows/nsFilePicker.cpp(780) : error C2440: '=' : cannot convert from 'nullptr' to 'WCHAR'
        A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
make[4]: *** [nsFilePicker.obj] Error 2
Should be 0, 0, L'\0' respectively.  Making them all 0 would work too.
Attached patch patchSplinter Review
I made use of NULL instead for the string pointers.
(and function pointers)
Attachment #645286 - Flags: review?(netzen)
(In reply to Jim Mathies [:jimm] from comment #3)
> I made use of NULL instead for the string pointers.

There are no string pointers or function pointers here.  The first one is an int, and the last is a WCHAR (= wchar_t).  NULL will work too because it's defined to be 0 anyway, but IMO it's clearer only to use it for pointers.
Attachment #645286 - Flags: review?(netzen) → review+
Ah, your right, iImage is an int. lpfn is a function though, which is fine with NULL, and the NULL terminator I can make a '\0'.
Comment on attachment 645286 [details] [diff] [review]
patch

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

::: widget/windows/nsFilePicker.cpp
@@ +538,5 @@
>    browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
>    browserInfo.lpszTitle      = mTitle.get();
>    browserInfo.ulFlags        = BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
>    browserInfo.hwndOwner      = adtw.get(); 
> +  browserInfo.iImage         = NULL;

This is an index so you might as well use 0 here too.

@@ +776,5 @@
>            if (GetLastError() == ERROR_INVALID_PARAMETER ||
>                CommDlgExtendedError() == FNERR_INVALIDFILENAME) {
>              // Probably the default file name is too long or contains illegal
>              // characters. Try again, without a starting file name.
> +            ofn.lpstrFile[0] = NULL;

Agreed with previous comment. But use L'\0'
https://hg.mozilla.org/mozilla-central/rev/34e8766ffabd
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla17
You need to log in before you can comment on or make changes to this bug.