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

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

@ -341,6 +341,20 @@ nsXBLService::FlushBindings(nsIContent* aContent)
if (!bindable)
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
return NS_OK;
}

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

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

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

@ -341,6 +341,20 @@ nsXBLService::FlushBindings(nsIContent* aContent)
if (!bindable)
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
return NS_OK;
}