diff --git a/xpcom/base/nsISupportsUtils.h b/xpcom/base/nsISupportsUtils.h index 66c61ba1b031..5284fb96cc67 100644 --- a/xpcom/base/nsISupportsUtils.h +++ b/xpcom/base/nsISupportsUtils.h @@ -607,6 +607,24 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ PR_END_MACRO #endif +/** + * Macro for releasing a reference to an interface. + * + * Note that when MOZ_TRACE_XPCOM_REFCNT is defined that the release will + * be done before the trace message is logged. If the reference count + * goes to zero and implementation of Release logs a message, the two + * messages will be logged out of order. + * + * @param _ptr The interface pointer. + */ +#ifdef MOZ_TRACE_XPCOM_REFCNT +#define NS_RELEASE_THIS() \ + nsTraceRefcnt::Release(this, Release(), __FILE__, __LINE__) +#else +#define NS_RELEASE_THIS() \ + Release() +#endif + /** * Macro for releasing a reference to an interface, except that this * macro preserves the return value from the underlying Release call. diff --git a/xpcom/glue/nsISupportsUtils.h b/xpcom/glue/nsISupportsUtils.h index 66c61ba1b031..5284fb96cc67 100644 --- a/xpcom/glue/nsISupportsUtils.h +++ b/xpcom/glue/nsISupportsUtils.h @@ -607,6 +607,24 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \ PR_END_MACRO #endif +/** + * Macro for releasing a reference to an interface. + * + * Note that when MOZ_TRACE_XPCOM_REFCNT is defined that the release will + * be done before the trace message is logged. If the reference count + * goes to zero and implementation of Release logs a message, the two + * messages will be logged out of order. + * + * @param _ptr The interface pointer. + */ +#ifdef MOZ_TRACE_XPCOM_REFCNT +#define NS_RELEASE_THIS() \ + nsTraceRefcnt::Release(this, Release(), __FILE__, __LINE__) +#else +#define NS_RELEASE_THIS() \ + Release() +#endif + /** * Macro for releasing a reference to an interface, except that this * macro preserves the return value from the underlying Release call.