WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
27001
Fix improper use of PassRefPtr<Node> to RefPtr<Node>
https://bugs.webkit.org/show_bug.cgi?id=27001
Summary
Fix improper use of PassRefPtr<Node> to RefPtr<Node>
David Kilzer (:ddkilzer)
Reported
2009-07-06 14:13:41 PDT
Created
attachment 32318
[details]
Patch v1 Fix improper use of PassRefPtr<Node> to RefPtr<Node> Reviewed by NOBODY (OOPS!). PassRefPtr<> should only be used for arguments to functions that take ownership of the object, or as return values from functions that relinquish ownership of the object. * editing/Editor.cpp: (WebCore::Editor::increaseSelectionListLevelOrdered): Changed stack-allocated PassRefPtr<Node> to RefPtr<Node> and call release() on returned object to prevent ref count churn. (WebCore::Editor::increaseSelectionListLevelUnordered): Ditto.
Attachments
Patch v1
(3.10 KB, patch)
2009-07-06 14:13 PDT
,
David Kilzer (:ddkilzer)
ggaren
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Geoffrey Garen
Comment 1
2009-07-06 14:16:11 PDT
Comment on
attachment 32318
[details]
Patch v1
> (WebCore::Editor::increaseSelectionListLevelOrdered): Changed > stack-allocated PassRefPtr<Node> to RefPtr<Node> and call > release() on returned object to prevent ref count churn.
Technically, I don't think there would be refcount churn, since the default behavior of PassRefPtr is to give up its reference upon assignment: template <typename U> PassRefPtr(const PassRefPtr<U>& o) : m_ptr(o.releaseRef()) { } However, this is still a good change for the style reasons you cited.
David Kilzer (:ddkilzer)
Comment 2
2009-07-06 17:55:45 PDT
(In reply to
comment #1
)
> (From update of
attachment 32318
[details]
) > > (WebCore::Editor::increaseSelectionListLevelOrdered): Changed > > stack-allocated PassRefPtr<Node> to RefPtr<Node> and call > > release() on returned object to prevent ref count churn. > > Technically, I don't think there would be refcount churn, since the default > behavior of PassRefPtr is to give up its reference upon assignment: > > template <typename U> PassRefPtr(const PassRefPtr<U>& o) : > m_ptr(o.releaseRef()) { }
I'll adjust the changelog entry. (If you didn't call release(), though, and returned the RefPtr<Node> object, I do believe some ref count churn would be involved creating a PassRefPtr<Node> from a RefPtr<Node>. That's what I was referring to when using release().)
David Kilzer (:ddkilzer)
Comment 3
2009-07-06 17:59:23 PDT
$ git svn dcommit Committing to
http://svn.webkit.org/repository/webkit/trunk
... M WebCore/ChangeLog M WebCore/editing/Editor.cpp Committed
r45577
http://trac.webkit.org/changeset/45577
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