Bug 961551, part 7 - Smart pointerize rootClasp. r=bholley

Also, move the declaration of |clasp| down to where it is used.
This commit is contained in:
Andrew McCreight 2014-01-21 17:56:16 -08:00
parent d7fc298807
commit a065e0f69c

View File

@ -328,7 +328,6 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
AutoJSContext cx; AutoJSContext cx;
JSObject2WrappedJSMap* map; JSObject2WrappedJSMap* map;
nsRefPtr<nsXPCWrappedJSClass> clasp;
XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance(); XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
map = rt->GetWrappedJSMap(); map = rt->GetWrappedJSMap();
@ -337,6 +336,7 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsRefPtr<nsXPCWrappedJSClass> clasp;
nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, getter_AddRefs(clasp)); nsXPCWrappedJSClass::GetNewOrUsed(cx, aIID, getter_AddRefs(clasp));
if (!clasp) if (!clasp)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -363,14 +363,13 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
return NS_OK; return NS_OK;
} else { } else {
// just a root wrapper // just a root wrapper
nsXPCWrappedJSClass* rootClasp = nullptr; nsRefPtr<nsXPCWrappedJSClass> rootClasp;
nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports), nsXPCWrappedJSClass::GetNewOrUsed(cx, NS_GET_IID(nsISupports),
&rootClasp); getter_AddRefs(rootClasp));
if (!rootClasp) if (!rootClasp)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
root = new nsXPCWrappedJS(cx, rootJSObj, rootClasp, nullptr); root = new nsXPCWrappedJS(cx, rootJSObj, rootClasp, nullptr);
NS_RELEASE(rootClasp);
} }
} }