Closed Bug 227489 Opened 22 years ago Closed 20 years ago

nsIWidget::GetParent and GetChildren should not return raw addrefed pointers

Categories

(Core :: Web Painting, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(1 file)

GetParent() and GetChildren() should return already_AddRefed (or GetParent() should maybe just return a weak pointer).
OS: Linux → All
Hardware: PC → All
Whiteboard: [good first bug]
Summary: nsIWidget should not return raw addrefed pointers → nsIWidget::GetParent and GetChildren should not return raw addrefed pointers
*** Bug 251527 has been marked as a duplicate of this bug. ***
Note that GetChildren() is gone. All that's left is GetParent().
So.. Instead of: nsIWidget* nsWidget::GetParent(void) { nsIWidget *ret; ret = mParent; NS_IF_ADDREF(ret); return ret; } do we want: already_AddRefed<nsIWidget> nsWidget::GetParent() { return do_QueryReferent(mParent); } , assuming mParent is an nsWeakPtr?
No, we want: nsIWidget* GetParent() const { return mParent; } (mParent is not an nsWeakPtr). Then we need to find all callers of this method and audit them to make sure that nothing bad will happen. This is the part that's pretty nontrivial to do. :(
(In reply to comment #4) > Then we need to find all callers of this method and audit them to make sure that > nothing bad will happen. This is the part that's pretty nontrivial to do. :( Okay. Should the callers have a strong reference to the returned pointer while they're using it?
Depends on the caller. All the ones that can get away with holding a weak ref (i.e. all the ones that don't do anything that could destroy the widget) should do so.
I looked at all GetParent() callers in the tree, and things look ok. Note that this fixes an accessibility leak...
Attachment #215193 - Flags: superreview?(roc)
Attachment #215193 - Flags: review?(roc)
Attachment #215193 - Flags: superreview?(roc)
Attachment #215193 - Flags: superreview+
Attachment #215193 - Flags: review?(roc)
Attachment #215193 - Flags: review+
roc, could you possibly land that for me? I won't have a chance to watch the tree for at least 5 days, maybe more, and this sort of thing rots easily. :(
(In reply to comment #7) > Note that this fixes an accessibility leak... Where?
Assignee: roc → bzbarsky
Whiteboard: [good first bug]
Target Milestone: --- → mozilla1.9alpha
Fixed.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Component: Layout: View Rendering → Layout: Web Painting
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: