GlobalWindowImpl::SetNewDocument: fixed multiple initialization of JSContext. Always clears the scope first.

This commit is contained in:
beard%netscape.com 1999-04-02 06:22:00 +00:00
parent 65b1f8f077
commit c9f141a9a0

View File

@ -213,19 +213,18 @@ GlobalWindowImpl::SetContext(nsIScriptContext *aContext)
NS_IMETHODIMP_(void)
GlobalWindowImpl::SetNewDocument(nsIDOMDocument *aDocument)
{
if (nsnull != mDocument) {
ClearAllTimeouts();
ClearAllTimeouts();
if (nsnull != mScriptObject && nsnull != mContext) {
JS_ClearScope((JSContext *)mContext->GetNativeContext(),
(JSObject *)mScriptObject);
}
NS_RELEASE(mDocument);
if (nsnull != mContext) {
mContext->GC();
}
if (nsnull != mScriptObject && nsnull != mContext) {
JS_ClearScope((JSContext *)mContext->GetNativeContext(),
(JSObject *)mScriptObject);
}
if (nsnull != mDocument)
NS_RELEASE(mDocument);
if (nsnull != mContext)
mContext->GC();
mDocument = aDocument;