Closed Bug 370029 Opened 18 years ago Closed 18 years ago

Stop using gParentWnd in nsDeviceContextSpecWin

Categories

(Core :: Widget: Win32, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: sharparrow1, Assigned: sharparrow1)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch Patch (obsolete) — Splinter Review
Straigntforward patch.

The primary justification for doing this is the subsequent removal of the aWidget parameter to nsIDeviceContextSpec::Init.  Also, using a global to store an hwnd is very dangerous, and could crash if DisplayPropertiesDlg were ever actually called on Windows.
Attachment #254704 - Flags: review?(emaijala)
(I just noticed the spelling error; fixed in my tree.)
Comment on attachment 254704 [details] [diff] [review]
Patch

You could still use the window handle in Init even though it's not stored in a global anymore, no? At least MSDN isn't saying hWnd can be NULL so it's better it isn't.

Make DisplayPropertiesDlg return NS_OK so we're on par with most of the other implementations.
Attachment #254704 - Flags: review?(emaijala) → review-
(In reply to comment #2)
> (From update of attachment 254704 [details] [diff] [review])
> You could still use the window handle in Init even though it's not stored in a
> global anymore, no? At least MSDN isn't saying hWnd can be NULL so it's better
> it isn't.

Passing in NULL is perfectly safe if you're not asking DocumentProperties to display anything.  Logically, it wouldn't make any sense, because the settings for a printer shouldn't change depending on which window you happen to be asking from. Microsoft examples have no problem passing in NULL (i.e. http://support.microsoft.com/kb/140285).

Plus, we aren't even guaranteed that Init() will be called before GetDataFromPrinter (see InitPrintSettingsFromPrinter, and nsGlobalWindow::Print which calls it).  We've been passing in NULL for DocumentProperties already without any problems.

I'd like to get rid of the aWidget parameter to nsIDeviceContextSpec::Init, and that's dependent on not using it anymore on Windows.

> Make DisplayPropertiesDlg return NS_OK so we're on par with most of the other
> implementations.

Okay.
Attached patch Patch v2Splinter Review
Attachment #254704 - Attachment is obsolete: true
Attachment #255553 - Flags: review?(emaijala)
Comment on attachment 255553 [details] [diff] [review]
Patch v2

Ok then :) r=emaijala
Attachment #255553 - Flags: review?(emaijala) → review+
Attachment #255553 - Flags: superreview?(roc)
Attachment #255553 - Flags: superreview?(roc) → superreview+
Checked in.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: