[Webkit-unassigned] [Bug 78404] [chromium] Replace RefPtr with OwnPtr for CCLayerImpl tree structure

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 24 18:44:42 PST 2012


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





--- Comment #22 from James Robinson <jamesr at chromium.org>  2012-02-24 18:44:43 PST ---
(In reply to comment #21) 
> > > Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp:323
> > > +    CCLayerImpl* child2 = CCLayerImpl::create(3).leakPtr();
> > 
> > This is unnecessarily confusing - leakPtr() pretty much always means that there's a leak and requires special care, in this case the code looks buggy unless you look down to the adoptPtr() call 9 lines below.  I think what you really want here is to have child2 be an OwnPtr<> and .release() it in the addChild() call.
> 
> Then again we have the problem that child2 will be null after the release() call...
> I'll limit the scope of child2 in cases like this, then declare another raw pointer child2 later on if used. Sounds better?
> 

I think that sounds like the right approach.  It still may be awkward in some cases, but IMO awkward-looking code without leakPtr() is generally either obvious to correct or very reliably fails.  It's difficult to write a subtle memory leak or race without leakPtr().

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list