From 1a0a3e63ccac1da732b52d3ab1b55e824a79f748 Mon Sep 17 00:00:00 2001 From: "markh%activestate.com" Date: Wed, 22 Aug 2001 04:11:28 +0000 Subject: [PATCH] Fix a subtle bug in the weak-reference support - the weak reference must always be made against the "base" interface for the instance, not one of the tear-offs (as the tear-off may have a shorter life than the base) Not part of the build. git-svn-id: svn://10.0.0.236/trunk@101617 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/extensions/python/xpcom/src/PyGBase.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mozilla/extensions/python/xpcom/src/PyGBase.cpp b/mozilla/extensions/python/xpcom/src/PyGBase.cpp index 5a4c3ceaace..34ec66cff8d 100644 --- a/mozilla/extensions/python/xpcom/src/PyGBase.cpp +++ b/mozilla/extensions/python/xpcom/src/PyGBase.cpp @@ -387,8 +387,15 @@ PyG_Base::Release(void) NS_IMETHODIMP PyG_Base::GetWeakReference(nsIWeakReference **ret) { + // always delegate back to the "base" gateway for the object, as this tear-off + // interface may not live as long as the base. So we recurse back to the base. + if (m_pBaseObject) { + NS_PRECONDITION(m_pWeakRef == nsnull, "Not a base object, but do have a weak-ref!"); + return m_pBaseObject->GetWeakReference(ret); + } NS_PRECONDITION(ret, "null pointer"); if (ret==nsnull) return NS_ERROR_INVALID_POINTER; + // explicit QI back to nsISupports if (!m_pWeakRef) { // First query for a weak reference - create it. m_pWeakRef = new PyXPCOM_GatewayWeakReference(this);