Made a protected method for severing weak references early

git-svn-id: svn://10.0.0.236/trunk@48602 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
scc%netscape.com 1999-09-21 20:20:04 +00:00
parent 9b023f2539
commit 240063823f
2 changed files with 48 additions and 6 deletions

View File

@ -51,6 +51,10 @@ class NS_COM nsSupportsWeakReference : public nsISupportsWeakReference
}
nsWeakReference* mProxy;
protected:
inline void ClearWeakReferences();
};
class NS_COM nsWeakReference : public nsIWeakReference
@ -93,10 +97,27 @@ class NS_COM nsWeakReference : public nsIWeakReference
nsSupportsWeakReference* mReferent;
};
inline nsSupportsWeakReference::~nsSupportsWeakReference()
inline
void
nsSupportsWeakReference::ClearWeakReferences()
/*
Usually being called from |nsSupportsWeakReference::~nsSupportsWeakReference|
will be good enough, but you may have a case where you need to call disconnect
your weak references in an outer destructor (to prevent some client holding a
weak reference from re-entering your destructor).
*/
{
if ( mProxy )
{
mProxy->NoticeReferentDestruction();
mProxy = 0;
}
}
inline
nsSupportsWeakReference::~nsSupportsWeakReference()
{
if ( mProxy )
mProxy->NoticeReferentDestruction();
ClearWeakReferences();
}
#endif

View File

@ -51,6 +51,10 @@ class NS_COM nsSupportsWeakReference : public nsISupportsWeakReference
}
nsWeakReference* mProxy;
protected:
inline void ClearWeakReferences();
};
class NS_COM nsWeakReference : public nsIWeakReference
@ -93,10 +97,27 @@ class NS_COM nsWeakReference : public nsIWeakReference
nsSupportsWeakReference* mReferent;
};
inline nsSupportsWeakReference::~nsSupportsWeakReference()
inline
void
nsSupportsWeakReference::ClearWeakReferences()
/*
Usually being called from |nsSupportsWeakReference::~nsSupportsWeakReference|
will be good enough, but you may have a case where you need to call disconnect
your weak references in an outer destructor (to prevent some client holding a
weak reference from re-entering your destructor).
*/
{
if ( mProxy )
{
mProxy->NoticeReferentDestruction();
mProxy = 0;
}
}
inline
nsSupportsWeakReference::~nsSupportsWeakReference()
{
if ( mProxy )
mProxy->NoticeReferentDestruction();
ClearWeakReferences();
}
#endif