Closed Bug 1167403 Opened 10 years ago Closed 10 years ago

Mark gfxFont::GlyphChangeObserver::mFont as MOZ_NON_OWNING_REF

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla41
Tracking Status
firefox41 --- fixed

People

(Reporter: nika, Assigned: nika)

Details

(Whiteboard: [gfx-noted])

Attachments

(1 file, 1 obsolete file)

Comment on attachment 8609020 [details] [diff] [review] Make gfcFont::GlyphChangeObserver::mFont a smart pointer Review of attachment 8609020 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/thebes/gfxFont.h @@ +1769,5 @@ > explicit GlyphChangeObserver(gfxFont *aFont) : mFont(aFont) > { > mFont->AddGlyphChangeObserver(this); > } > + nsRefPtr<gfxFont> mFont; It looks like mFont was a weak reference. Will making it a strong reference cause it to leak?
First time I looked through I noticed that gfxFont keeps a reference to the GlyphChangeObserver through the member mGlyphChangeObservers. This member is a nsAutoPtr<nsTHashtable<nsPtrHashKey<GlyphChangeObserver> > >, and the nsPtrHashKey entry type doesn't own it's inner pointer - it only holds a weak reference to it. So I thought it made sense to make this change. You may be right, however, that this change would cause a memory leak. I've looked a bit closer and noticed that gfxFont's destructor enumerates through the hashtable entries, deleting the mFont property with ForgetFont. I'll update the patch to instead mark this member as MOZ_NON_OWNING_REF, and add a comment explaining this.
Summary: Make gfxFont::GlyphChangeObserver::mFont a smart pointer → Mark gfxFont::GlyphChangeObserver::mFont as MOZ_NON_OWNING_REF
Comment on attachment 8609393 [details] [diff] [review] Mark gfxFont::GlyphChangeObserver::mFont as MOZ_NON_OWNING_REF John is a more appropriate reviewer
Attachment #8609393 - Flags: review?(jmuizelaar) → review?(jdaggett)
Whiteboard: [gfx-noted]
Attachment #8609393 - Flags: review?(jdaggett) → review+
Assignee: nobody → michael
Keywords: checkin-needed
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla41
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: