Last Comment Bug 770598 - Clean up NS_NewSVGDocument()
: Clean up NS_NewSVGDocument()
Product: Core
Classification: Components
Component: SVG (show other bugs)
: Trunk
: x86_64 Linux
-- normal (vote)
: mozilla16
Assigned To: Daniel Holbert [:dholbert]
: Jet Villegas (:jet)
Depends on:
  Show dependency treegraph
Reported: 2012-07-03 10:53 PDT by Daniel Holbert [:dholbert]
Modified: 2012-07-07 12:03 PDT (History)
2 users (show)
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

fix (889 bytes, patch)
2012-07-03 11:21 PDT, Daniel Holbert [:dholbert]
jwatt: review+
Details | Diff | Splinter Review

Description User image Daniel Holbert [:dholbert] 2012-07-03 10:53:39 PDT
decoder was just asking me about some unused-by-tests code in nsSVGDocument.cpp, and one of the lines for checking the result of "new" in  NS_NewSVGDocument().

I'm filing this bug on removing that and doing a bit of other fixup in that function (using a nsRefPtr rather than a manual ADDREF / RELEASE)
Comment 1 User image Daniel Holbert [:dholbert] 2012-07-03 11:21:51 PDT
Created attachment 638810 [details] [diff] [review]

This matches the pattern that we use in NS_NewSVG##_elementName##Element(), with nsRefPtr etc.:

The only difference is that I removed the null-check after "new", since it's infallible.
Comment 2 User image Jonathan Watt [:jwatt] 2012-07-05 03:06:16 PDT
Comment on attachment 638810 [details] [diff] [review]

longsonr is on vacation for a few weeks, so taking review.
Comment 3 User image Daniel Holbert [:dholbert] 2012-07-06 10:51:23 PDT
Comment 4 User image :Ms2ger (⌚ UTC+1/+2) 2012-07-06 14:15:40 PDT
Comment on attachment 638810 [details] [diff] [review]

Review of attachment 638810 [details] [diff] [review]:

::: content/svg/document/src/nsSVGDocument.cpp
@@ +112,4 @@
>      return rv;
>    }
> +  *aInstancePtrResult = doc.forget().get();

Exactly what doc.forget(aInstancePtrResult) is for
Comment 5 User image Daniel Holbert [:dholbert] 2012-07-06 14:35:09 PDT
Ah, nice -- I thought there was something like that.  (FWIW, I was copypasting an existing pattern, for maximum foolproof-ness, as noted in comment 1.)

Probably worth doing an MXR search for "forget().get()" and replacing with forget().  Ms2ger, perhaps you'd be interested in filing and either fixing or mentoring? :)
Comment 6 User image Ryan VanderMeulen [:RyanVM] 2012-07-07 12:03:03 PDT

Note You need to log in before you can comment on or make changes to this bug.