[Webkit-unassigned] [Bug 173266] Objects owning API clients should use UniqueRef

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jun 13 22:31:40 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=173266

--- Comment #11 from Carlos Garcia Campos <cgarcia at igalia.com> ---
(In reply to Carlos Garcia Campos from comment #10)
> (In reply to Alex Christensen from comment #8)
> > I think it's better to use UniqueRef and to use makeUniqueRef to make them. 
> > If you can't go to the source of these std::unique_ptrs and replace them
> > with makeUniqueRef, let's leave them as std::unique_ptrs for now.
> 
> The problem is not the source of the unique_ptrs, but the setters. This is
> what we do:
> 
> void setClient(std::unique_ptr<Client> client)
> {
>     if (!client)
>         m_client = std::make_unique<Client>();
>     else
>         m_client = WTFMove(client);
> }
> 
> There's no problem in using makeUniqueRef there, the problem is that the
> setter can't receive a null client if we use UniqueRef as the parameter. I
> guess we can still do this, keeping the unique_ptr as the parameter and
> leaking it to adopt it by the UniqueRef. I added the UniqueRef just for
> convenience.

hmm, I don't think this is possible either, and using std::optional for the parameter would only make it more complex, IMO, so I'm going to leave the unique_ptrs. I can reuse this bug to not pass the clients by value and use an rvalue ref like you and Darin suggested.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170614/66caf0fe/attachment.html>


More information about the webkit-unassigned mailing list