diff --git a/js/src/xpconnect/src/xpcprivate.h b/js/src/xpconnect/src/xpcprivate.h index 7e676ffa4db..d1c0e8af62e 100644 --- a/js/src/xpconnect/src/xpcprivate.h +++ b/js/src/xpconnect/src/xpcprivate.h @@ -1371,6 +1371,7 @@ private: nsDeque* mJSContextStack; JSContext* mSafeJSContext; xpcPerThreadData* mNextThread; + PRBool mSafeContextIsFromSetter; static PRLock* gLock; static xpcPerThreadData* gThreads; diff --git a/js/src/xpconnect/src/xpcthreadcontext.cpp b/js/src/xpconnect/src/xpcthreadcontext.cpp index bf3f2c0430b..f59a0a0deab 100644 --- a/js/src/xpconnect/src/xpcthreadcontext.cpp +++ b/js/src/xpconnect/src/xpcthreadcontext.cpp @@ -198,7 +198,8 @@ xpcPerThreadData::xpcPerThreadData() : mException(nsnull), mJSContextStack(new nsDeque(nsnull)), mSafeJSContext(nsnull), - mNextThread(nsnull) + mNextThread(nsnull), + mSafeContextIsFromSetter(PR_FALSE) { if(gLock) { @@ -219,7 +220,7 @@ xpcPerThreadData::Cleanup() mJSContextStack = nsnull; } - if(mSafeJSContext) + if(mSafeJSContext && !mSafeContextIsFromSetter) { JS_DestroyContext(mSafeJSContext); mSafeJSContext = nsnull; @@ -328,8 +329,8 @@ xpcPerThreadData::GetSafeJSContext() nsresult xpcPerThreadData::SetSafeJSContext(JSContext *cx) { - NS_ASSERTION(!mSafeJSContext, "SetSafeJSContext called too late!"); mSafeJSContext = cx; + mSafeContextIsFromSetter = PR_TRUE; return NS_OK; }