зеркало из https://github.com/mozilla/pjs.git
Fix leak of preferences JS context by making prefs hold a reference to the JS runtime service and using that reference to avoid "runtime mismatch, leaking context" under normal conditions. b=76288 r=shaver, bnesse sr=waterson
This commit is contained in:
Родитель
b2c1b3b770
Коммит
b5094fcf5c
|
@ -60,6 +60,9 @@ static nsresult openPrefFileSpec(nsIFileSpec* aFilespec, PRBool aIsErrorFatal, P
|
||||||
static nsresult savePrefFile(nsIFile* aFile);
|
static nsresult savePrefFile(nsIFile* aFile);
|
||||||
|
|
||||||
|
|
||||||
|
// needed so we can still get the JS Runtime Service during XPCOM shutdown
|
||||||
|
static nsIJSRuntimeService* gJSRuntimeService = nsnull; // owning reference
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor/Destructor
|
* Constructor/Destructor
|
||||||
|
@ -81,6 +84,7 @@ nsPrefService::~nsPrefService()
|
||||||
{
|
{
|
||||||
PREF_Cleanup();
|
PREF_Cleanup();
|
||||||
NS_IF_RELEASE(mCurrentFile);
|
NS_IF_RELEASE(mCurrentFile);
|
||||||
|
NS_IF_RELEASE(gJSRuntimeService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -714,16 +718,20 @@ extern "C" JSRuntime* PREF_GetJSRuntime()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsIJSRuntimeService> rtsvc =
|
if (!gJSRuntimeService) {
|
||||||
do_GetService("@mozilla.org/js/xpc/RuntimeService;1", &rv);
|
rv = CallGetService("@mozilla.org/js/xpc/RuntimeService;1",
|
||||||
if (NS_SUCCEEDED(rv)) {
|
&gJSRuntimeService);
|
||||||
JSRuntime* rt;
|
if (NS_FAILED(rv)) {
|
||||||
rv = rtsvc->GetRuntime(&rt);
|
NS_WARNING("nsJSRuntimeService is missing");
|
||||||
if (NS_SUCCEEDED(rv)) {
|
gJSRuntimeService = nsnull;
|
||||||
return rt;
|
return nsnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NS_WARNING("nsJSRuntimeService is missing");
|
|
||||||
|
JSRuntime* rt;
|
||||||
|
rv = gJSRuntimeService->GetRuntime(&rt);
|
||||||
|
if (NS_SUCCEEDED(rv))
|
||||||
|
return rt;
|
||||||
return nsnull;
|
return nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче