Make it possible to construct a RefPtr from an already_AddRefed; r=froydnj

RESOLVED FIXED in mozilla38

Status

()

defect
RESOLVED FIXED
5 years ago
4 years ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

unspecified
mozilla38
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

This will pave the way towards having a MakeAndAddRef function
that returns an already_AddRefed and can be used in graphics code.
Assignee: nobody → ehsan
Blocks: 1116905
Attachment #8548910 - Flags: review?(nfroyd)
Comment on attachment 8548910 [details] [diff] [review]
Make it possible to construct a RefPtr from an already_AddRefed

Review of attachment 8548910 [details] [diff] [review]:
-----------------------------------------------------------------

Um, this compiles?  already_AddRefed::take is non-const.
Attachment #8548910 - Flags: review?(nfroyd)
(In reply to Nathan Froyd [:froydnj] [:nfroyd] from comment #2)
> Comment on attachment 8548910 [details] [diff] [review]
> Make it possible to construct a RefPtr from an already_AddRefed
> 
> Review of attachment 8548910 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> Um, this compiles?  already_AddRefed::take is non-const.

Sigh, templates.  Yes, you're right, but the compiler didn't know this because I had yet to instantiate the constructor!
This will pave the way towards having a MakeAndAddRef function
that returns an already_AddRefed and can be used in graphics code.
Attachment #8550791 - Flags: review?(nfroyd)
Attachment #8548910 - Attachment is obsolete: true
Comment on attachment 8550791 [details] [diff] [review]
Make it possible to construct a RefPtr from an already_AddRefed

Review of attachment 8550791 [details] [diff] [review]:
-----------------------------------------------------------------

r=me with fixing the compile error.

::: mfbt/RefPtr.h
@@ +255,5 @@
>      return *this;
>    }
> +  RefPtr& operator=(const already_AddRefed<T>& aOther)
> +  {
> +    assign(aOther.take());

...and I guess this doesn't compile, either, because |take()| is non-const?
Attachment #8550791 - Flags: review?(nfroyd) → review+
https://hg.mozilla.org/mozilla-central/rev/b9c534b922c7
https://hg.mozilla.org/mozilla-central/rev/793fb5d20398
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
Duplicate of this bug: 776358
You need to log in before you can comment on or make changes to this bug.