зеркало из https://github.com/mozilla/gecko-dev.git
make xpcshell use jsrtsvc, and let jsrtsvc handle JS_Shutdown (r=jband)
This commit is contained in:
Родитель
cca5e191f9
Коммит
c182ce4717
|
@ -48,6 +48,7 @@
|
|||
#include "nscore.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIJSRuntimeService.h"
|
||||
|
||||
// all this crap is needed to do the interactive shell stuff
|
||||
#include <stdlib.h>
|
||||
|
@ -605,9 +606,16 @@ main(int argc, char **argv)
|
|||
|
||||
SetupRegistry();
|
||||
|
||||
NS_WITH_SERVICE(nsIJSRuntimeService, rtsvc, "nsJSRuntimeService", &rv);
|
||||
// get the JSRuntime from the runtime svc, if possible
|
||||
if (NS_FAILED(rv) ||
|
||||
NS_FAILED(rtsvc->GetRuntime(&rt))) {
|
||||
rtsvc = NULL;
|
||||
rt = JS_NewRuntime(8L * 1024L * 1024L);
|
||||
}
|
||||
if (!rt)
|
||||
return 1;
|
||||
|
||||
jscontext = JS_NewContext(rt, 8192);
|
||||
if (!jscontext)
|
||||
return 1;
|
||||
|
@ -653,8 +661,11 @@ main(int argc, char **argv)
|
|||
xpc->AbandonJSContext(jscontext);
|
||||
NS_RELEASE(xpc);
|
||||
JS_DestroyContext(jscontext);
|
||||
if (!rtsvc) {
|
||||
/* no runtime service, so we have to handle shutdown */
|
||||
JS_DestroyRuntime(rt);
|
||||
JS_ShutDown();
|
||||
}
|
||||
|
||||
rv = NS_ShutdownXPCOM( NULL );
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "NS_ShutdownXPCOM failed");
|
||||
|
|
|
@ -33,11 +33,13 @@ nsJSRuntimeServiceImpl::nsJSRuntimeServiceImpl() :
|
|||
}
|
||||
|
||||
nsJSRuntimeServiceImpl::~nsJSRuntimeServiceImpl() {
|
||||
if (mRuntime)
|
||||
if (mRuntime) {
|
||||
JS_DestroyRuntime(mRuntime);
|
||||
JS_ShutDown();
|
||||
#ifdef DEBUG_shaver
|
||||
fprintf(stderr, "nJRSI: destroyed runtime %p\n", mRuntime);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsJSRuntimeServiceImpl, nsIJSRuntimeService);
|
||||
|
|
Загрузка…
Ссылка в новой задаче