PSA: Deleting implicit conversion from raw pointer to rtc::scoped_refptr

86 views
Skip to first unread message

Niels Moller

unread,
Jan 20, 2022, 11:21:21 AMJan 20
to discuss...@googlegroups.com
Many webrtc objects are reference counted, both internally, and in the advertised C++ PeerConnection API, with references managed via the "smart pointer " type rtc::scoped_refptr (which predates std::shared_ptr, and works a bit different).

For historical reasons, the rtc::scoped_refptr class supports implicit conversion to and from raw pointer; one can pass a T* wherever a rtc::scoped_refptr<T> is expected and vice versa, and these implicit conversions makes ownership of objects much less visible.

I intend to delete implicit conversion in one direction, from raw pointer to rtc::scoped_refptr, soon, but at the earliest two weeks from now, February 3. The planned change is in https://webrtc-review.googlesource.com/c/src/+/247362, note that the special case of implicit conversion from nullptr is kept.

When this change lands, applications will need to change any existing implicit conversions to explicitly use the appropriate rtc::scoped_refptr constructor. For examples of what needed changes will look like, see https://webrtc-review.googlesource.com/c/src/+/242363, updating webrtc itself, and https://chromium-review.googlesource.com/c/chromium/src/+/3398124, updating chromium. The rtc::make_ref_counted utility used in a few places in webrtc will at some point be moved to webrtc's advertised api/ folder, but not right away.

Implicit conversion in the other direction, from rtc::scoped_refptr<T> to T*, without using the .get() method, will hopefully be deleted too, at some later time.

Please see bugs.webrtc.org/13464 for context and feedback.

Regards,
/Niels Möller

Niels Moller

unread,
May 6, 2022, 3:13:22 AMMay 6
to discuss...@googlegroups.com
Preparations now complete for this next step, see  https://webrtc-review.googlesource.com/c/src/+/260325, to be landed soon.

Please see bugs.webrtc.org/13464 for context and feedback.

Regarsd,
/Niels 
Reply all
Reply to author
Forward
0 new messages