WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
158269
Allow RefPtrs of const types
https://bugs.webkit.org/show_bug.cgi?id=158269
Summary
Allow RefPtrs of const types
Alex Christensen
Reported
2016-06-01 13:39:03 PDT
Allow RefPtrs of const types
Attachments
Patch
(2.51 KB, patch)
2016-06-01 13:41 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(2.50 KB, patch)
2016-06-02 00:56 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Patch
(4.85 KB, patch)
2016-06-07 09:42 PDT
,
Alex Christensen
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Alex Christensen
Comment 1
2016-06-01 13:41:24 PDT
Created
attachment 280262
[details]
Patch
Alexey Proskuryakov
Comment 2
2016-06-01 19:34:30 PDT
Comment on
attachment 280262
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=280262&action=review
> Source/WTF/wtf/RefCounted.h:145 > + delete const_cast<T*>(static_cast<const T*>(this));
Was this change actually needed?
Alex Christensen
Comment 3
2016-06-02 00:56:56 PDT
Created
attachment 280315
[details]
Patch
Alex Christensen
Comment 4
2016-06-02 00:57:32 PDT
A change was needed, but the const_cast was not.
Anders Carlsson
Comment 5
2016-06-02 19:52:51 PDT
I wonder if we should make RefPtr do the cast instead.
Alex Christensen
Comment 6
2016-06-02 20:12:39 PDT
This allows you to make a RefPtr<const X> but making a RefPtr<X> from a RefPtr<const X> doesn't work because it sees those types as unrelated.
Darin Adler
Comment 7
2016-06-03 19:53:19 PDT
(In reply to
comment #6
)
> This allows you to make a RefPtr<const X> but making a RefPtr<X> from a > RefPtr<const X> doesn't work because it sees those types as unrelated.
I think you mean that making a RefPtr<const X> from a RefPtr<X> doesn’t work. Because that other one should not work!
Darin Adler
Comment 8
2016-06-03 19:54:18 PDT
I’m OK with this change, but I’d like to see test coverage for this in Tools/TestWebKitAPI/Tests/WTF.
Alex Christensen
Comment 9
2016-06-07 09:42:58 PDT
Created
attachment 280713
[details]
Patch
Alex Christensen
Comment 10
2016-06-07 09:44:09 PDT
(In reply to
comment #7
)
> (In reply to
comment #6
) > > This allows you to make a RefPtr<const X> but making a RefPtr<X> from a > > RefPtr<const X> doesn't work because it sees those types as unrelated. > > I think you mean that making a RefPtr<const X> from a RefPtr<X> doesn’t > work. Because that other one should not work!
Yep, I got those backwards. I thought I was running into template weirdness when using this, but I added a test and it compiles fine. I'll fix it if I run into it again and something is actually wrong.
Darin Adler
Comment 11
2016-06-09 20:22:43 PDT
(In reply to
comment #5
)
> I wonder if we should make RefPtr do the cast instead.
Did you have a reply to Anders about this, Alex?
Brent Fulgham
Comment 12
2016-06-16 15:46:23 PDT
Comment on
attachment 280713
[details]
Patch This seems like a good change, but I'd feel better if Anders or Sam glanced at it before we landed it.
Alex Christensen
Comment 13
2016-06-20 13:26:00 PDT
(In reply to
comment #11
)
> (In reply to
comment #5
) > > I wonder if we should make RefPtr do the cast instead. > > Did you have a reply to Anders about this, Alex?
I prefer this approach because RefCounted changing the ref count and deleting the object when the last ref is gone does not mutate the object itself, but if you implemented your own ref/deref functions that did mutate the object significantly, then you would not want a RefPtr<const YourType> to be possible.
WebKit Commit Bot
Comment 14
2016-07-14 17:01:26 PDT
Comment on
attachment 280713
[details]
Patch Clearing flags on attachment: 280713 Committed
r203257
: <
http://trac.webkit.org/changeset/203257
>
WebKit Commit Bot
Comment 15
2016-07-14 17:01:32 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug