зеркало из 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 "nsISupports.idl"
|
||||||
#include "nsIException.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
|
interface nsIXPCException : nsIException
|
||||||
{
|
{
|
||||||
// inherits methods from nsIException
|
// inherits methods from nsIException
|
||||||
|
@ -53,6 +60,10 @@ interface nsIXPCException : nsIException
|
||||||
in nsIStackFrame aLocation,
|
in nsIStackFrame aLocation,
|
||||||
in nsISupports aData,
|
in nsISupports aData,
|
||||||
in nsIException aInner);
|
in nsIException aInner);
|
||||||
|
|
||||||
|
[noscript] xpcexJSVal stealJSVal();
|
||||||
|
[noscript] void stowJSVal(in xpcexJSContextPtr cx,
|
||||||
|
in xpcexJSVal val);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* this goes into the C++ header verbatim. */
|
/* 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)
|
if(NS_SUCCEEDED(res) && cx && jsExceptionPtr && *exceptn)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsXPCException> xpcEx = do_QueryInterface(*exceptn);
|
nsCOMPtr<nsIXPCException> xpcEx = do_QueryInterface(*exceptn);
|
||||||
if(xpcEx)
|
if(xpcEx)
|
||||||
xpcEx->StowThrownJSVal(cx, *jsExceptionPtr);
|
xpcEx->StowJSVal(cx, *jsExceptionPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sz)
|
if(sz)
|
||||||
|
|
|
@ -151,22 +151,28 @@ nsXPCException::~nsXPCException()
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
PRBool
|
/* [noscript] xpcexJSVal stealJSVal (); */
|
||||||
nsXPCException::StealThrownJSVal(jsval *vp)
|
NS_IMETHODIMP
|
||||||
|
nsXPCException::StealJSVal(jsval *vp NS_OUTPARAM)
|
||||||
{
|
{
|
||||||
if(mThrownJSVal.IsHeld())
|
if(mThrownJSVal.IsHeld())
|
||||||
{
|
{
|
||||||
*vp = mThrownJSVal.Release();
|
*vp = mThrownJSVal.Release();
|
||||||
return PR_TRUE;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
return PR_FALSE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/* [noscript] void stowJSVal (in xpcexJSContextPtr cx, in xpcexJSVal val); */
|
||||||
nsXPCException::StowThrownJSVal(JSContext *cx, jsval v)
|
NS_IMETHODIMP
|
||||||
|
nsXPCException::StowJSVal(JSContext* cx, jsval v)
|
||||||
{
|
{
|
||||||
if (mThrownJSVal.Hold(cx))
|
if(mThrownJSVal.Hold(cx))
|
||||||
|
{
|
||||||
mThrownJSVal = v;
|
mThrownJSVal = v;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -2982,9 +2982,6 @@ public:
|
||||||
|
|
||||||
static void InitStatics() { sEverMadeOneFromFactory = JS_FALSE; }
|
static void InitStatics() { sEverMadeOneFromFactory = JS_FALSE; }
|
||||||
|
|
||||||
PRBool StealThrownJSVal(jsval* vp);
|
|
||||||
void StowThrownJSVal(JSContext* cx, jsval v);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Reset();
|
void Reset();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -301,7 +301,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
|
||||||
JSBool success = JS_FALSE;
|
JSBool success = JS_FALSE;
|
||||||
if(e)
|
if(e)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsXPCException> xpcEx;
|
nsCOMPtr<nsIXPCException> xpcEx;
|
||||||
jsval thrown;
|
jsval thrown;
|
||||||
nsXPConnect* xpc;
|
nsXPConnect* xpc;
|
||||||
|
|
||||||
|
@ -310,7 +310,7 @@ XPCThrower::ThrowExceptionObject(JSContext* cx, nsIException* e)
|
||||||
// context (i.e., not chrome), rethrow the original value.
|
// context (i.e., not chrome), rethrow the original value.
|
||||||
if(!IsCallerChrome(cx) &&
|
if(!IsCallerChrome(cx) &&
|
||||||
(xpcEx = do_QueryInterface(e)) &&
|
(xpcEx = do_QueryInterface(e)) &&
|
||||||
xpcEx->StealThrownJSVal(&thrown))
|
NS_SUCCEEDED(xpcEx->StealJSVal(&thrown)))
|
||||||
{
|
{
|
||||||
JS_SetPendingException(cx, thrown);
|
JS_SetPendingException(cx, thrown);
|
||||||
success = JS_TRUE;
|
success = JS_TRUE;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче