diff --git a/mozilla/js/src/xpconnect/src/xpcprivate.h b/mozilla/js/src/xpconnect/src/xpcprivate.h index 6ce9ba3e79d..0eda2553a12 100644 --- a/mozilla/js/src/xpconnect/src/xpcprivate.h +++ b/mozilla/js/src/xpconnect/src/xpcprivate.h @@ -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 diff --git a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp index b9124a03a6b..2f5ca750cd8 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappedjs.cpp @@ -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) {