зеркало из https://github.com/mozilla/pjs.git
Bug 467865 - [@ js_RemoveRoot - ... - XPCThrower::ThrowExceptionObject] xpconnect is misusing nsCOMPtr. r=jonas+sr=jst
This commit is contained in:
Родитель
29771df1cf
Коммит
1c669214fe
|
@ -42,7 +42,14 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIException.idl"
|
||||
|
||||
[scriptable, uuid(b2a34010-3983-11d3-9888-006008962422)]
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
[ptr] native xpcexJSContextPtr(JSContext);
|
||||
native xpcexJSVal(jsval);
|
||||
|
||||
[scriptable, uuid(cac29630-7bf2-4e22-811b-46855a7d5af0)]
|
||||
interface nsIXPCException : nsIException
|
||||
{
|
||||
// inherits methods from nsIException
|
||||
|
@ -53,6 +60,10 @@ interface nsIXPCException : nsIException
|
|||
in nsIStackFrame aLocation,
|
||||
in nsISupports aData,
|
||||
in nsIException aInner);
|
||||
|
||||
[noscript] xpcexJSVal stealJSVal();
|
||||
[noscript] void stowJSVal(in xpcexJSContextPtr cx,
|
||||
in xpcexJSVal val);
|
||||
};
|
||||
|
||||
/* this goes into the C++ header verbatim. */
|
||||
|
|
|
@ -1428,9 +1428,9 @@ XPCConvert::ConstructException(nsresult rv, const char* message,
|
|||
|
||||
if(NS_SUCCEEDED(res) && cx && jsExceptionPtr && *exceptn)
|
||||
{
|
||||
nsCOMPtr<nsXPCException> xpcEx = do_QueryInterface(*exceptn);
|
||||
nsCOMPtr<nsIXPCException> xpcEx = do_QueryInterface(*exceptn);
|
||||
if(xpcEx)
|
||||
xpcEx->StowThrownJSVal(cx, *jsExceptionPtr);
|
||||
xpcEx->StowJSVal(cx, *jsExceptionPtr);
|
||||
}
|
||||
|
||||
if(sz)
|
||||
|
|
|
@ -151,22 +151,28 @@ nsXPCException::~nsXPCException()
|
|||
Reset();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsXPCException::StealThrownJSVal(jsval *vp)
|
||||
/* [noscript] xpcexJSVal stealJSVal (); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCException::StealJSVal(jsval *vp NS_OUTPARAM)
|
||||
{
|
||||
if(mThrownJSVal.IsHeld())
|
||||
{
|
||||
*vp = mThrownJSVal.Release();
|
||||
return PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
return PR_FALSE;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
nsXPCException::StowThrownJSVal(JSContext *cx, jsval v)
|
||||
/* [noscript] void stowJSVal (in xpcexJSContextPtr cx, in xpcexJSVal val); */
|
||||
NS_IMETHODIMP
|
||||
nsXPCException::StowJSVal(JSContext* cx, jsval v)
|
||||
{
|
||||
if (mThrownJSVal.Hold(cx))
|
||||
if(mThrownJSVal.Hold(cx))
|
||||
{
|
||||
mThrownJSVal = v;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -2982,9 +2982,6 @@ public:
|
|||
|
||||
static void InitStatics() { sEverMadeOneFromFactory = JS_FALSE; }
|
||||
|
||||
PRBool StealThrownJSVal(jsval* vp);
|
||||
void StowThrownJSVal(JSContext* cx, jsval v);
|
||||
|
||||
protected:
|
||||
void Reset();
|
||||
private:
|
||||
|
|
|
@ -301,7 +301,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
|
|||
JSBool success = JS_FALSE;
|
||||
if(e)
|
||||
{
|
||||
nsCOMPtr<nsXPCException> xpcEx;
|
||||
nsCOMPtr<nsIXPCException> xpcEx;
|
||||
jsval thrown;
|
||||
nsXPConnect* xpc;
|
||||
|
||||
|
@ -310,7 +310,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
|
|||
// context (i.e., not chrome), rethrow the original value.
|
||||
if(!IsCallerChrome(cx) &&
|
||||
(xpcEx = do_QueryInterface(e)) &&
|
||||
xpcEx->StealThrownJSVal(&thrown))
|
||||
NS_SUCCEEDED(xpcEx->StealJSVal(&thrown)))
|
||||
{
|
||||
JS_SetPendingException(cx, thrown);
|
||||
success = JS_TRUE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче