Closed Bug 971817 Opened 10 years ago Closed 10 years ago

gfxPlatform::GetLog should decide if it's static or not

Categories

(Core :: Graphics: Text, defect)

28 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla30

People

(Reporter: milan, Assigned: milan)

Details

Attachments

(1 file, 1 obsolete file)

gfxPlatform::GetLog is static, so it can be called without using gfxPlatform::GetPlatform(), which means it can be called without the singleton getting created and gfxPlatform::Init() being called.

gfxPlatform::GetLog, however, uses file statics that are only initialized in gfxPlatform::Init.  So, if anybody calls gfxPlatform::GetLog() before gfxPlatform::GetPlatform() is called, they will get a wrong result.

Right now, nsPresContext constructor calls gfxPlatform::GetLog() and that happens before gfxPlatform::GetPlatform() call, so the value is wrong.

To be safe, we should just make gfxPlatform::GetLog() a non-static, so that it needs to be accessed as gfxPlatform::GetPlatform()->GetLog() instead.

Alternatively, the initialization of those statics should be done in GetLog() rather than Init().
John, any preference?  Seven files call GetLog(), so more files will be touched if we make this non-static, but I'm not sure just the size of the patch should be guiding us here.
Assignee: nobody → milan
Flags: needinfo?(jdaggett)
Changed the summary to remove the solution suggestion.
Summary: gfxPlatform::GetLog should probably not be static? → gfxPlatform::GetLog should decide if it's static or not
Here's an option where we just initialize those logs when we need them.
Attachment #8374970 - Flags: review?(jdaggett)
Flags: needinfo?(jdaggett)
Comment on attachment 8374970 [details] [diff] [review]
Make gfxPlatform::GetLog responsible for having the correct logs, rather than count on gfxPlatform::Init() getting called first.

Yup, looks good.
Attachment #8374970 - Flags: review?(jdaggett) → review+
No longer blocks: 971126
https://hg.mozilla.org/mozilla-central/rev/a99d7db15f4a
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla30
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: