зеркало из https://github.com/mozilla/pjs.git
make certain that the JSRuntimeService singleton does not go away before the xpconnect singleton. Fix for bug 25093. r=ssu@netscape.com
This commit is contained in:
Родитель
3ea70b12c7
Коммит
89900282d1
|
@ -274,14 +274,14 @@ nsXPConnect::nsXPConnect()
|
|||
|
||||
nsXPConnect::~nsXPConnect()
|
||||
{
|
||||
if(mRuntime)
|
||||
delete mRuntime;
|
||||
if(mThrower)
|
||||
delete mThrower;
|
||||
NS_IF_RELEASE(mArbitraryScriptable);
|
||||
NS_IF_RELEASE(mInterfaceInfoManager);
|
||||
NS_IF_RELEASE(mContextStack);
|
||||
NS_IF_RELEASE(mDefaultSecurityManager);
|
||||
if(mThrower)
|
||||
delete mThrower;
|
||||
if(mRuntime)
|
||||
delete mRuntime;
|
||||
gSelf = nsnull;
|
||||
}
|
||||
|
||||
|
@ -445,12 +445,11 @@ JSBool
|
|||
nsXPConnect::CreateRuntime()
|
||||
{
|
||||
NS_ASSERTION(!mRuntime,"CreateRuntime called but mRuntime already init'd");
|
||||
JSRuntime* rt;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIJSRuntimeService, rtsvc, "nsJSRuntimeService", &rv);
|
||||
if(NS_SUCCEEDED(rv) && NS_SUCCEEDED(rtsvc->GetRuntime(&rt)))
|
||||
if(NS_SUCCEEDED(rv) && rtsvc)
|
||||
{
|
||||
mRuntime = XPCJSRuntime::newXPCJSRuntime(this, rt);
|
||||
mRuntime = XPCJSRuntime::newXPCJSRuntime(this, rtsvc);
|
||||
}
|
||||
return nsnull != mRuntime;
|
||||
}
|
||||
|
|
|
@ -98,12 +98,14 @@ XPCJSRuntime::~XPCJSRuntime()
|
|||
|
||||
if(mMapLock)
|
||||
PR_DestroyLock(mMapLock);
|
||||
NS_IF_RELEASE(mJSRuntimeService);
|
||||
}
|
||||
|
||||
XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect,
|
||||
JSRuntime* aJSRuntime)
|
||||
nsIJSRuntimeService* aJSRuntimeService)
|
||||
: mXPConnect(aXPConnect),
|
||||
mJSRuntime(aJSRuntime),
|
||||
mJSRuntime(nsnull),
|
||||
mJSRuntimeService(aJSRuntimeService),
|
||||
mContextMap(JSContext2XPCContextMap::newMap(XPC_CONTEXT_MAP_SIZE)),
|
||||
mWrappedJSMap(JSObject2WrappedJSMap::newMap(XPC_JS_MAP_SIZE)),
|
||||
mWrappedJSClassMap(IID2WrappedJSClassMap::newMap(XPC_JS_CLASS_MAP_SIZE)),
|
||||
|
@ -112,22 +114,29 @@ XPCJSRuntime::XPCJSRuntime(nsXPConnect* aXPConnect,
|
|||
{
|
||||
// these jsids filled in later when we have a JSContext to work with.
|
||||
mStrIDs[0] = 0;
|
||||
}
|
||||
|
||||
if(mJSRuntimeService)
|
||||
{
|
||||
NS_ADDREF(mJSRuntimeService);
|
||||
mJSRuntimeService->GetRuntime(&mJSRuntime);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
XPCJSRuntime*
|
||||
XPCJSRuntime::newXPCJSRuntime(nsXPConnect* aXPConnect,
|
||||
JSRuntime* aJSRuntime)
|
||||
nsIJSRuntimeService* aJSRuntimeService)
|
||||
{
|
||||
NS_PRECONDITION(aXPConnect,"bad param");
|
||||
NS_PRECONDITION(aJSRuntime,"bad param");
|
||||
NS_PRECONDITION(aJSRuntimeService,"bad param");
|
||||
|
||||
XPCJSRuntime* self;
|
||||
|
||||
self = new XPCJSRuntime(aXPConnect,
|
||||
aJSRuntime);
|
||||
aJSRuntimeService);
|
||||
|
||||
if(self &&
|
||||
self->GetJSRuntime() &&
|
||||
self->GetContextMap() &&
|
||||
self->GetWrappedJSMap() &&
|
||||
self->GetWrappedJSClassMap() &&
|
||||
|
|
|
@ -58,9 +58,9 @@ PR_STATIC_CALLBACK(void)
|
|||
xpcModuleDtor(nsIModule* self)
|
||||
{
|
||||
// Release our singletons
|
||||
nsXPConnect::ReleaseXPConnectSingleton();
|
||||
nsXPCThreadJSContextStackImpl::FreeSingleton();
|
||||
nsJSRuntimeServiceImpl::FreeSingleton();
|
||||
nsXPConnect::ReleaseXPConnectSingleton();
|
||||
}
|
||||
|
||||
NS_IMPL_NSGETMODULE_WITH_DTOR("xpconnect", components, xpcModuleDtor)
|
||||
|
|
|
@ -173,7 +173,7 @@ class XPCJSRuntime
|
|||
{
|
||||
public:
|
||||
static XPCJSRuntime* newXPCJSRuntime(nsXPConnect* aXPConnect,
|
||||
JSRuntime* aJSRuntime);
|
||||
nsIJSRuntimeService* aJSRuntimeService);
|
||||
|
||||
JSRuntime* GetJSRuntime() const {return mJSRuntime;}
|
||||
nsXPConnect* GetXPConnect() const {return mXPConnect;}
|
||||
|
@ -224,7 +224,7 @@ public:
|
|||
private:
|
||||
XPCJSRuntime(); // no implementation
|
||||
XPCJSRuntime(nsXPConnect* aXPConnect,
|
||||
JSRuntime* aJSRuntime);
|
||||
nsIJSRuntimeService* aJSRuntimeService);
|
||||
|
||||
JSContext2XPCContextMap* GetContextMap() const {return mContextMap;}
|
||||
JSBool GenerateStringIDs(JSContext* cx);
|
||||
|
@ -235,6 +235,7 @@ private:
|
|||
|
||||
nsXPConnect* mXPConnect;
|
||||
JSRuntime* mJSRuntime;
|
||||
nsIJSRuntimeService* mJSRuntimeService; // hold this to hold the JSRuntime
|
||||
JSContext2XPCContextMap* mContextMap;
|
||||
JSObject2WrappedJSMap* mWrappedJSMap;
|
||||
IID2WrappedJSClassMap* mWrappedJSClassMap;
|
||||
|
|
|
@ -668,11 +668,10 @@ int main()
|
|||
|
||||
cxstack = nsnull; // release service held by nsCOMPtr
|
||||
xpc = nsnull; // release service held by nsCOMPtr
|
||||
rtsvc = nsnull; // release service held by nsCOMPtr
|
||||
|
||||
rv = NS_ShutdownXPCOM( NULL );
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
||||
|
||||
rtsvc = nsnull; // release service held by nsCOMPtr
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче