Checking in the real fix for 34130.

This commit is contained in:
hyatt%netscape.com 2000-04-03 07:13:07 +00:00
Родитель 1a8756d781
Коммит bcab583ed6
4 изменённых файлов: 68 добавлений и 44 удалений

Просмотреть файл

@ -333,12 +333,11 @@ nsXBLBinding::nsXBLBinding(void)
} }
} }
/**
* Removes a root inadvertently left over. // Error code that ensures the binding clears
* This is really an error condition, but I've written // out its script object, even in cases where it should
* this to prevent the JS GC from asserting. // have done so earlier.
*/ static nsresult RemoveRoot(void* aSlot)
static nsresult removeRoot(void* aSlot)
{ {
const char kJSRuntimeServiceProgID[] = "nsJSRuntimeService"; const char kJSRuntimeServiceProgID[] = "nsJSRuntimeService";
nsresult rv; nsresult rv;
@ -348,14 +347,13 @@ static nsresult removeRoot(void* aSlot)
rv = runtimeService->GetRuntime(&rt); rv = runtimeService->GetRuntime(&rt);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return (JS_RemoveRootRT(rt, aSlot) ? NS_OK : NS_ERROR_FAILURE); return (JS_RemoveRootRT(rt, aSlot) ? NS_OK : NS_ERROR_FAILURE);
} }
nsXBLBinding::~nsXBLBinding(void) nsXBLBinding::~nsXBLBinding(void)
{ {
NS_ASSERTION(!mScriptObject, "XBL binding hasn't properly cleared its script object out.");
if (mScriptObject) { if (mScriptObject) {
removeRoot(&mScriptObject); RemoveRoot(&mScriptObject);
mScriptObject = nsnull; mScriptObject = nsnull;
} }

Просмотреть файл

@ -341,6 +341,20 @@ nsXBLService::FlushBindings(nsIContent* aContent)
if (!bindable) if (!bindable)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Get the original binding.
nsCOMPtr<nsIXBLBinding> binding;
bindable->GetBinding(getter_AddRefs(binding));
if (binding) {
// Clear out the script references.
nsCOMPtr<nsIDocument> document;
aContent->GetDocument(*getter_AddRefs(document));
nsCOMPtr<nsIScriptGlobalObject> global;
document->GetScriptGlobalObject(getter_AddRefs(global));
nsCOMPtr<nsIScriptContext> context;
global->GetContext(getter_AddRefs(context));
binding->RemoveScriptReferences(context);
}
bindable->SetBinding(nsnull); // Flush old bindings bindable->SetBinding(nsnull); // Flush old bindings
return NS_OK; return NS_OK;
} }

Просмотреть файл

@ -333,12 +333,11 @@ nsXBLBinding::nsXBLBinding(void)
} }
} }
/**
* Removes a root inadvertently left over. // Error code that ensures the binding clears
* This is really an error condition, but I've written // out its script object, even in cases where it should
* this to prevent the JS GC from asserting. // have done so earlier.
*/ static nsresult RemoveRoot(void* aSlot)
static nsresult removeRoot(void* aSlot)
{ {
const char kJSRuntimeServiceProgID[] = "nsJSRuntimeService"; const char kJSRuntimeServiceProgID[] = "nsJSRuntimeService";
nsresult rv; nsresult rv;
@ -348,14 +347,13 @@ static nsresult removeRoot(void* aSlot)
rv = runtimeService->GetRuntime(&rt); rv = runtimeService->GetRuntime(&rt);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return (JS_RemoveRootRT(rt, aSlot) ? NS_OK : NS_ERROR_FAILURE); return (JS_RemoveRootRT(rt, aSlot) ? NS_OK : NS_ERROR_FAILURE);
} }
nsXBLBinding::~nsXBLBinding(void) nsXBLBinding::~nsXBLBinding(void)
{ {
NS_ASSERTION(!mScriptObject, "XBL binding hasn't properly cleared its script object out.");
if (mScriptObject) { if (mScriptObject) {
removeRoot(&mScriptObject); RemoveRoot(&mScriptObject);
mScriptObject = nsnull; mScriptObject = nsnull;
} }

Просмотреть файл

@ -341,6 +341,20 @@ nsXBLService::FlushBindings(nsIContent* aContent)
if (!bindable) if (!bindable)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// Get the original binding.
nsCOMPtr<nsIXBLBinding> binding;
bindable->GetBinding(getter_AddRefs(binding));
if (binding) {
// Clear out the script references.
nsCOMPtr<nsIDocument> document;
aContent->GetDocument(*getter_AddRefs(document));
nsCOMPtr<nsIScriptGlobalObject> global;
document->GetScriptGlobalObject(getter_AddRefs(global));
nsCOMPtr<nsIScriptContext> context;
global->GetContext(getter_AddRefs(context));
binding->RemoveScriptReferences(context);
}
bindable->SetBinding(nsnull); // Flush old bindings bindable->SetBinding(nsnull); // Flush old bindings
return NS_OK; return NS_OK;
} }