Browse files

Bug 584551 - Do things that require entering a request on the old com…

…partment before entering a request on the new one. r=igor a=blocking-beta3

--HG--
branch : GECKO20b3_20100804_RELBRANCH
  • Loading branch information...
1 parent a11bdaa commit f58a53f42f1891537a3e92e1088168d991f6c93f @mrbkap mrbkap committed Aug 5, 2010
Showing with 12 additions and 11 deletions.
  1. +12 −11 js/src/xpconnect/src/xpccallcontext.cpp
View
23 js/src/xpconnect/src/xpccallcontext.cpp
@@ -146,14 +146,6 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
return;
}
- // Get into the request as early as we can to avoid problems with scanning
- // callcontexts on other threads from within the gc callbacks.
-
- NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
- "Don't call JS_BeginRequest unless the caller is native.");
- if(callBeginRequest)
- JS_BeginRequest(mJSContext);
-
if(topJSContext != mJSContext)
{
if(NS_FAILED(stack->Push(mJSContext)))
@@ -164,6 +156,14 @@ XPCCallContext::Init(XPCContext::LangType callerLanguage,
mContextPopRequired = JS_TRUE;
}
+ // Get into the request as early as we can to avoid problems with scanning
+ // callcontexts on other threads from within the gc callbacks.
+
+ NS_ASSERTION(!callBeginRequest || mCallerLanguage == NATIVE_CALLER,
+ "Don't call JS_BeginRequest unless the caller is native.");
+ if(callBeginRequest)
+ JS_BeginRequest(mJSContext);
+
mXPCContext = XPCContext::GetXPCContext(mJSContext);
mPrevCallerLanguage = mXPCContext->SetCallingLangType(mCallerLanguage);
@@ -386,6 +386,10 @@ XPCCallContext::~XPCCallContext()
shouldReleaseXPC = mPrevCallContext == nsnull;
}
+ // NB: Needs to happen before the context stack pop.
+ if(mJSContext && mCallerLanguage == NATIVE_CALLER)
+ JS_EndRequest(mJSContext);
+
if(mContextPopRequired)
{
XPCJSContextStack* stack = mThreadData->GetJSContextStack();
@@ -404,9 +408,6 @@ XPCCallContext::~XPCCallContext()
if(mJSContext)
{
- if(mCallerLanguage == NATIVE_CALLER)
- JS_EndRequest(mJSContext);
-
if(mDestroyJSContextInDestructor)
{
#ifdef DEBUG_xpc_hacker

0 comments on commit f58a53f

Please sign in to comment.