Open
Bug 1179374
Opened 10 years ago
Updated 3 years ago
add addRefIntoOutparam(T**)/copyAndAddRef methods to smart pointer classes
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
NEW
People
(Reporter: froydnj, Unassigned)
Details
Looking at some of the patterns of NS_ADDREF we have in the tree, one reasonably common one is:
nsRefPtr<Class> mFoo;
...
NS_ADDREF(*aOutFoo = mFoo);
return NS_OK;
I think changing this, in the spirit of .forget(T**), to:
mFoo.addRefIntoOutparam(aOutFoo);
return NS_OK;
would be an improvement.
Equally, as we move away from XPCOM outparam semantics, one sometimes sees (this is particularly common in gfx code):
nsRefPtr<Class> mFoo;
already_AddRefed<Class>
Outer::Method(...)
{
nsRefPtr<Class> copy(mFoo);
return copy.forget();
}
we should have a helper method to just say:
return mFoo.copyAndAddRef();
(This is admittedly kind of a hack to workaround our non-use of move semantics for smart pointer return values.)
Bikeshedding on the names welcome.
Updated•3 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•