fix bug 76102. Only vend weak references from the root of a wrappedJS wrapper chain. r=dbaron sr=brendan

git-svn-id: svn://10.0.0.236/trunk@92531 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jband%netscape.com
2001-04-17 07:22:52 +00:00
parent 04d62928b5
commit 656bc99a3e
2 changed files with 15 additions and 3 deletions

View File

@@ -772,6 +772,7 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSIXPCONNECTJSOBJECTHOLDER
NS_DECL_NSIXPCONNECTWRAPPEDJS
NS_DECL_NSISUPPORTSWEAKREFERENCE
// Note that both nsXPTCStubBase and nsIXPConnectWrappedJS declare
// GetInterfaceInfo methods with the same sig. So, the declaration

View File

@@ -161,14 +161,25 @@ do_decrement:
JS_RemoveRootRT(rt->GetJSRuntime(), &mJSObj);
}
// If we are not being used from a weak reference, then this extra
// ref is not needed and we can let ourself be deleted.
if(!mRoot->HasWeakReferences())
// If we are not the root wrapper or if we are not being used from a
// weak reference, then this extra ref is not needed and we can let
// ourself be deleted.
// Note: HasWeakReferences() could only return true for the root.
if(!HasWeakReferences())
goto do_decrement;
}
return cnt;
}
NS_IMETHODIMP
nsXPCWrappedJS::GetWeakReference(nsIWeakReference** aInstancePtr)
{
if(mRoot != this)
return mRoot->GetWeakReference(aInstancePtr);
return nsSupportsWeakReference::GetWeakReference(aInstancePtr);
}
NS_IMETHODIMP
nsXPCWrappedJS::GetJSObject(JSObject** aJSObj)
{