Bug 239925 - fix static initializers in DOM/widget/libpr0n so that we can restart XPCOM safely r=jst sr=darin

This commit is contained in:
bsmedberg%covad.net 2004-06-09 18:36:25 +00:00
parent 7f56cb9f8f
commit a7deb4f150
10 changed files with 35 additions and 11 deletions

View File

@ -44,7 +44,6 @@
#include "nsNetUtil.h"
#include "nsIObserverService.h"
#include "nsIServiceManagerUtils.h"
#include "nsIProfileChangeStatus.h"
NS_IMPL_ISUPPORTS1(nsLayoutStylesheetCache, nsIObserver)

View File

@ -251,6 +251,7 @@ void
CSSLoaderImpl::Shutdown()
{
delete gParsers;
gParsers = nsnull;
}
NS_IMETHODIMP

View File

@ -1280,10 +1280,6 @@ nsDOMClassInfo::RegisterExternalClasses()
#define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if) \
{ \
nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
NS_ASSERTION(!d.mProtoChainInterface, "Redeclaration of DOM classinfo " \
"proto chain interface!"); \
NS_ASSERTION(!d.mInterfaces, "Redeclaration of DOM classinfo " \
"interface list!"); \
d.mProtoChainInterface = _ifptr; \
d.mHasClassInterface = _has_class_if; \
static const nsIID *interface_list[] = {
@ -2963,6 +2959,7 @@ nsDOMClassInfo::ShutDown()
NS_IF_RELEASE(sXPConnect);
NS_IF_RELEASE(sSecMan);
sIsInitialized = PR_FALSE;
}

View File

@ -111,6 +111,8 @@ static PRLogModuleInfo* gJSDiagnostics;
#define NS_GC_DELAY 2000 // ms
#define NS_FIRST_GC_DELAY 10000 // ms
// if you add statics here, add them to the list in nsJSEnvironment::Startup
static nsITimer *sGCTimer;
static PRBool sReadyForGC;
@ -126,6 +128,7 @@ static PRThread *gDOMThread;
static JSGCCallback gOldJSGCCallback;
static PRBool sIsInitialized;
static PRBool sDidShutdown;
static PRInt32 sContextCount;
@ -1915,13 +1918,30 @@ DOMGCCallback(JSContext *cx, JSGCStatus status)
return gOldJSGCCallback ? gOldJSGCCallback(cx, status) : JS_TRUE;
}
//static
void
nsJSEnvironment::Startup()
{
// initialize all our statics, so that we can restart XPCOM
sGCTimer = nsnull;
sReadyForGC = PR_FALSE;
gNameSpaceManager = nsnull;
sRuntimeService = nsnull;
sRuntime = nsnull;
gDOMThread = nsnull;
gOldJSGCCallback = nsnull;
sIsInitialized = PR_FALSE;
sDidShutdown = PR_FALSE;
sContextCount = 0;
sSecurityManager = nsnull;
gCollation = nsnull;
}
// static
nsresult
nsJSEnvironment::Init()
{
static PRBool isInitialized;
if (isInitialized) {
if (sIsInitialized) {
return NS_OK;
}
@ -1991,7 +2011,7 @@ nsJSEnvironment::Init()
rv = CallGetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &sSecurityManager);
isInitialized = NS_SUCCEEDED(rv);
sIsInitialized = NS_SUCCEEDED(rv);
return rv;
}

View File

@ -179,6 +179,9 @@ private:
static JSRuntime *sRuntime;
public:
// called from the module Ctor to initialize statics
static void Startup();
static nsresult Init();
static nsJSEnvironment *GetScriptingEnvironment();

View File

@ -100,6 +100,7 @@
#include "nsIXBLService.h"
#include "nsIFrameLoader.h"
#include "nsICaret.h"
#include "nsJSEnvironment.h"
#include "nsLayoutAtoms.h"
#include "nsPlainTextSerializer.h"
#include "mozSanitizingSerializer.h"
@ -255,7 +256,8 @@ Initialize(nsIModule* aSelf)
}
gInitialized = PR_TRUE;
nsJSEnvironment::Startup();
nsresult rv = nsContentUtils::Init();
if (NS_FAILED(rv)) {
NS_ERROR("Could not initialize nsContentUtils");

View File

@ -251,6 +251,7 @@ void
CSSLoaderImpl::Shutdown()
{
delete gParsers;
gParsers = nsnull;
}
NS_IMETHODIMP

View File

@ -44,7 +44,6 @@
#include "nsNetUtil.h"
#include "nsIObserverService.h"
#include "nsIServiceManagerUtils.h"
#include "nsIProfileChangeStatus.h"
NS_IMPL_ISUPPORTS1(nsLayoutStylesheetCache, nsIObserver)

View File

@ -100,6 +100,7 @@ void nsGifShutdown()
{
// Release cached buffers from zlib allocator
delete gGifAllocator;
gGifAllocator = nsnull;
}
#define MAX_HOLD 768 /* for now must be big enough for a cmap */

View File

@ -393,6 +393,7 @@ nsWindow::ReleaseGlobals()
gsGtkCursorCache[i] = nsnull;
}
}
gGlobalsInitialized = PR_FALSE;
}
NS_IMETHODIMP nsWindow::Destroy(void)