diff --git a/mozilla/content/xul/content/src/nsXULElement.cpp b/mozilla/content/xul/content/src/nsXULElement.cpp
index bc503a48b80..d06c8200889 100644
--- a/mozilla/content/xul/content/src/nsXULElement.cpp
+++ b/mozilla/content/xul/content/src/nsXULElement.cpp
@@ -694,7 +694,6 @@ RDFElementImpl::~RDFElementImpl()
NS_IF_RELEASE(mListenerManager);
if (mChildren) {
-#if 0
// Force child's parent to be null. This ensures that we don't
// have dangling pointers if a child gets leaked.
PRUint32 cnt;
@@ -706,7 +705,6 @@ RDFElementImpl::~RDFElementImpl()
child->SetParent(nsnull);
}
-#endif
NS_RELEASE(mChildren);
}
diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp
index 1953debe865..a740b90d874 100644
--- a/mozilla/docshell/base/nsWebShell.cpp
+++ b/mozilla/docshell/base/nsWebShell.cpp
@@ -4210,7 +4210,6 @@ nsWebShellFactory::nsWebShellFactory()
nsWebShellFactory::~nsWebShellFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult
diff --git a/mozilla/netwerk/mime/src/nsMIMEServiceFactory.cpp b/mozilla/netwerk/mime/src/nsMIMEServiceFactory.cpp
index 0c0a9809180..62289bba254 100644
--- a/mozilla/netwerk/mime/src/nsMIMEServiceFactory.cpp
+++ b/mozilla/netwerk/mime/src/nsMIMEServiceFactory.cpp
@@ -334,7 +334,6 @@ nsMIMEServiceFactory::nsMIMEServiceFactory(const nsCID &aClass,
nsMIMEServiceFactory::~nsMIMEServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerFactory.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerFactory.cpp
index 7c10fdee020..5ce2f7a79f1 100644
--- a/mozilla/netwerk/protocol/http/src/nsHTTPHandlerFactory.cpp
+++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandlerFactory.cpp
@@ -50,7 +50,6 @@ nsHTTPHandlerFactory::nsHTTPHandlerFactory(const nsCID &aClass)
nsHTTPHandlerFactory::~nsHTTPHandlerFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
diff --git a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
index 944d735fd4e..4338c919e4f 100644
--- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
+++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp
@@ -1017,7 +1017,6 @@ FTPDirListingFactory::FTPDirListingFactory(const nsCID &aClass,
FTPDirListingFactory::~FTPDirListingFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(FTPDirListingFactory, NS_GET_IID(nsIFactory));
diff --git a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp
index 00619395cb5..8aadd215861 100644
--- a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp
+++ b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp
@@ -383,7 +383,6 @@ MultiMixedFactory::MultiMixedFactory(const nsCID &aClass,
MultiMixedFactory::~MultiMixedFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(MultiMixedFactory, NS_GET_IID(nsIFactory));
diff --git a/mozilla/netwerk/streamconv/test/Converters.cpp b/mozilla/netwerk/streamconv/test/Converters.cpp
index 504c0f3a281..8253cfa2137 100644
--- a/mozilla/netwerk/streamconv/test/Converters.cpp
+++ b/mozilla/netwerk/streamconv/test/Converters.cpp
@@ -116,7 +116,6 @@ TestConverterFactory::TestConverterFactory(const nsCID &aClass,
TestConverterFactory::~TestConverterFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(TestConverterFactory, NS_GET_IID(nsIFactory));
diff --git a/mozilla/netwerk/test/TestStreamConv.cpp b/mozilla/netwerk/test/TestStreamConv.cpp
index 7b88cfefa5c..022199f901d 100644
--- a/mozilla/netwerk/test/TestStreamConv.cpp
+++ b/mozilla/netwerk/test/TestStreamConv.cpp
@@ -132,7 +132,6 @@ TestConverterFactory::TestConverterFactory(const nsCID &aClass,
TestConverterFactory::~TestConverterFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
diff --git a/mozilla/network/module/nsNetFactory.cpp b/mozilla/network/module/nsNetFactory.cpp
index 5325a1eb629..a0f8b92a796 100644
--- a/mozilla/network/module/nsNetFactory.cpp
+++ b/mozilla/network/module/nsNetFactory.cpp
@@ -73,7 +73,6 @@ nsNetFactory::nsNetFactory(const nsCID &aClass)
nsNetFactory::~nsNetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsNetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/profile/Acctidl/nsAccountServicesFactory.cpp b/mozilla/profile/Acctidl/nsAccountServicesFactory.cpp
index cbe2f75282b..6111717a690 100644
--- a/mozilla/profile/Acctidl/nsAccountServicesFactory.cpp
+++ b/mozilla/profile/Acctidl/nsAccountServicesFactory.cpp
@@ -71,7 +71,6 @@ AccountServicesFactoryImpl::AccountServicesFactoryImpl(const nsCID &aClass,
AccountServicesFactoryImpl::~AccountServicesFactoryImpl()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
diff --git a/mozilla/rdf/content/src/nsRDFElement.cpp b/mozilla/rdf/content/src/nsRDFElement.cpp
index bc503a48b80..d06c8200889 100644
--- a/mozilla/rdf/content/src/nsRDFElement.cpp
+++ b/mozilla/rdf/content/src/nsRDFElement.cpp
@@ -694,7 +694,6 @@ RDFElementImpl::~RDFElementImpl()
NS_IF_RELEASE(mListenerManager);
if (mChildren) {
-#if 0
// Force child's parent to be null. This ensures that we don't
// have dangling pointers if a child gets leaked.
PRUint32 cnt;
@@ -706,7 +705,6 @@ RDFElementImpl::~RDFElementImpl()
child->SetParent(nsnull);
}
-#endif
NS_RELEASE(mChildren);
}
diff --git a/mozilla/rdf/content/src/nsXULElement.cpp b/mozilla/rdf/content/src/nsXULElement.cpp
index bc503a48b80..d06c8200889 100644
--- a/mozilla/rdf/content/src/nsXULElement.cpp
+++ b/mozilla/rdf/content/src/nsXULElement.cpp
@@ -694,7 +694,6 @@ RDFElementImpl::~RDFElementImpl()
NS_IF_RELEASE(mListenerManager);
if (mChildren) {
-#if 0
// Force child's parent to be null. This ensures that we don't
// have dangling pointers if a child gets leaked.
PRUint32 cnt;
@@ -706,7 +705,6 @@ RDFElementImpl::~RDFElementImpl()
child->SetParent(nsnull);
}
-#endif
NS_RELEASE(mChildren);
}
diff --git a/mozilla/view/src/nsViewFactory.cpp b/mozilla/view/src/nsViewFactory.cpp
index 7d92ec0ec2f..6564401d892 100644
--- a/mozilla/view/src/nsViewFactory.cpp
+++ b/mozilla/view/src/nsViewFactory.cpp
@@ -63,7 +63,6 @@ nsViewFactory::nsViewFactory(const nsCID &aClass)
nsViewFactory::~nsViewFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS1(nsViewFactory, nsIFactory)
diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp
index 1953debe865..a740b90d874 100644
--- a/mozilla/webshell/src/nsWebShell.cpp
+++ b/mozilla/webshell/src/nsWebShell.cpp
@@ -4210,7 +4210,6 @@ nsWebShellFactory::nsWebShellFactory()
nsWebShellFactory::~nsWebShellFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult
diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
index 8081e84fe00..1b6c5c9e58a 100644
--- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
+++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
@@ -3424,7 +3424,6 @@ nsBrowserWindowFactory::nsBrowserWindowFactory()
nsBrowserWindowFactory::~nsBrowserWindowFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult
diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp
index af0a32f38f3..246ca03bfd1 100644
--- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp
+++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp
@@ -782,7 +782,6 @@ nsXPBaseWindowFactory::nsXPBaseWindowFactory()
//----------------------------------------------------------------------
nsXPBaseWindowFactory::~nsXPBaseWindowFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
//----------------------------------------------------------------------
diff --git a/mozilla/widget/src/beos/nsWidgetFactory.cpp b/mozilla/widget/src/beos/nsWidgetFactory.cpp
index 2f131d48976..347be6b690a 100644
--- a/mozilla/widget/src/beos/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/beos/nsWidgetFactory.cpp
@@ -121,7 +121,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/build/nsWinWidgetFactory.cpp b/mozilla/widget/src/build/nsWinWidgetFactory.cpp
index 4dbda5e09be..32698426fb4 100644
--- a/mozilla/widget/src/build/nsWinWidgetFactory.cpp
+++ b/mozilla/widget/src/build/nsWinWidgetFactory.cpp
@@ -243,9 +243,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
-
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
-
}
diff --git a/mozilla/widget/src/gtk/nsWidgetFactory.cpp b/mozilla/widget/src/gtk/nsWidgetFactory.cpp
index b2d84376292..2a941a5d977 100644
--- a/mozilla/widget/src/gtk/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/gtk/nsWidgetFactory.cpp
@@ -125,7 +125,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp b/mozilla/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp
index 4bece4d8923..5a0973b6ac6 100644
--- a/mozilla/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp
+++ b/mozilla/widget/src/motif/app_context/nsMotifAppContextServiceFactory.cpp
@@ -53,7 +53,6 @@ nsMotifAppContextServiceFactory::nsMotifAppContextServiceFactory(const nsCID &aC
nsMotifAppContextServiceFactory::~nsMotifAppContextServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsMotifAppContextServiceFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/src/motif/nsWidgetFactory.cpp b/mozilla/widget/src/motif/nsWidgetFactory.cpp
index 25757892f77..eeab71128f6 100644
--- a/mozilla/widget/src/motif/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/motif/nsWidgetFactory.cpp
@@ -123,7 +123,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/photon/nsWidgetFactory.cpp b/mozilla/widget/src/photon/nsWidgetFactory.cpp
index 2dca4edeead..c9ba9243604 100644
--- a/mozilla/widget/src/photon/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/photon/nsWidgetFactory.cpp
@@ -135,8 +135,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
PR_LOG(PhWidLog, PR_LOG_DEBUG,("nsWidgetFactory::~nsWidgetFactory Destructor Called\n"));
-
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/qt/nsWidgetFactory.cpp b/mozilla/widget/src/qt/nsWidgetFactory.cpp
index ef04a5919ac..9c282c94e9f 100644
--- a/mozilla/widget/src/qt/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/qt/nsWidgetFactory.cpp
@@ -127,7 +127,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitServiceFactory.cpp b/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitServiceFactory.cpp
index b74c9b0d202..d5aa1da3b1e 100644
--- a/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitServiceFactory.cpp
+++ b/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitServiceFactory.cpp
@@ -53,7 +53,6 @@ nsUnixToolkitServiceFactory::nsUnixToolkitServiceFactory(const nsCID &aClass) :
nsUnixToolkitServiceFactory::~nsUnixToolkitServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsUnixToolkitServiceFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/src/xlib/nsWidgetFactory.cpp b/mozilla/widget/src/xlib/nsWidgetFactory.cpp
index a9cb90e4af2..452681d1e14 100644
--- a/mozilla/widget/src/xlib/nsWidgetFactory.cpp
+++ b/mozilla/widget/src/xlib/nsWidgetFactory.cpp
@@ -100,7 +100,6 @@ nsWidgetFactory::nsWidgetFactory(const nsCID &aClass)
nsWidgetFactory::~nsWidgetFactory()
{
- NS_ASSERTION(mRefCnt == 0, "Reference count not zero in destructor");
}
nsresult nsWidgetFactory::QueryInterface(const nsIID &aIID,
diff --git a/mozilla/widget/src/xlib/window_service/nsXlibWindowServiceFactory.cpp b/mozilla/widget/src/xlib/window_service/nsXlibWindowServiceFactory.cpp
index b46ff21f0b8..dd17c5e8bbf 100644
--- a/mozilla/widget/src/xlib/window_service/nsXlibWindowServiceFactory.cpp
+++ b/mozilla/widget/src/xlib/window_service/nsXlibWindowServiceFactory.cpp
@@ -54,7 +54,6 @@ nsXlibWindowServiceFactory::nsXlibWindowServiceFactory(const nsCID &aClass) :
nsXlibWindowServiceFactory::~nsXlibWindowServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsXlibWindowServiceFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/timer/src/unix/gtk/nsTimerGtkFactory.cpp b/mozilla/widget/timer/src/unix/gtk/nsTimerGtkFactory.cpp
index 2b64613f448..81769f9b6eb 100644
--- a/mozilla/widget/timer/src/unix/gtk/nsTimerGtkFactory.cpp
+++ b/mozilla/widget/timer/src/unix/gtk/nsTimerGtkFactory.cpp
@@ -56,7 +56,6 @@ nsTimerGtkFactory::nsTimerGtkFactory(const nsCID &aClass) :
nsTimerGtkFactory::~nsTimerGtkFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTimerGtkFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp b/mozilla/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp
index 677cfa29a79..4c039664260 100644
--- a/mozilla/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp
+++ b/mozilla/widget/timer/src/unix/motif/nsTimerMotifFactory.cpp
@@ -56,7 +56,6 @@ nsTimerMotifFactory::nsTimerMotifFactory(const nsCID &aClass) :
nsTimerMotifFactory::~nsTimerMotifFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTimerMotifFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/timer/src/unix/qt/nsTimerQtFactory.cpp b/mozilla/widget/timer/src/unix/qt/nsTimerQtFactory.cpp
index e0f0ceb2f62..0686caa9401 100644
--- a/mozilla/widget/timer/src/unix/qt/nsTimerQtFactory.cpp
+++ b/mozilla/widget/timer/src/unix/qt/nsTimerQtFactory.cpp
@@ -56,7 +56,6 @@ nsTimerQtFactory::nsTimerQtFactory(const nsCID &aClass) :
nsTimerQtFactory::~nsTimerQtFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTimerQtFactory, nsIFactory::GetIID())
diff --git a/mozilla/widget/timer/src/unix/xlib/nsTimerXlibFactory.cpp b/mozilla/widget/timer/src/unix/xlib/nsTimerXlibFactory.cpp
index cd289f2a029..ffdb90e159f 100644
--- a/mozilla/widget/timer/src/unix/xlib/nsTimerXlibFactory.cpp
+++ b/mozilla/widget/timer/src/unix/xlib/nsTimerXlibFactory.cpp
@@ -56,7 +56,6 @@ nsTimerXlibFactory::nsTimerXlibFactory(const nsCID &aClass) :
nsTimerXlibFactory::~nsTimerXlibFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTimerXlibFactory, nsIFactory::GetIID())
diff --git a/mozilla/xpcom/base/nsAgg.h b/mozilla/xpcom/base/nsAgg.h
index c2b3741ed07..33a062d065f 100644
--- a/mozilla/xpcom/base/nsAgg.h
+++ b/mozilla/xpcom/base/nsAgg.h
@@ -112,6 +112,7 @@ _class::Internal::Release(void) \
--agg->mRefCnt; \
NS_LOG_RELEASE(this, agg->mRefCnt, #_class); \
if (agg->mRefCnt == 0) { \
+ agg->mRefCnt = 1; /* stabilize */ \
NS_DELETEXPCOM(agg); \
return 0; \
} \
diff --git a/mozilla/xpcom/base/nsISupportsUtils.h b/mozilla/xpcom/base/nsISupportsUtils.h
index 54aad2b905e..2c412701338 100644
--- a/mozilla/xpcom/base/nsISupportsUtils.h
+++ b/mozilla/xpcom/base/nsISupportsUtils.h
@@ -200,6 +200,15 @@ NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
/**
* Use this macro to implement the Release method for a given _class
* @param _class The name of the class implementing the method
+ *
+ * A note on the 'stabilization' of the refcnt to one. At that point,
+ * the object's refcount will have gone to zero. The object's
+ * destructor may trigger code that attempts to QueryInterface() and
+ * Release() 'this' again. Doing so will temporarily increment and
+ * decrement the refcount. (Only a logic error would make one try to
+ * keep a permanent hold on 'this'.) To prevent re-entering the
+ * destructor, we make sure that no balanced refcounting can return
+ * the refcount to |0|.
*/
#define NS_IMPL_RELEASE(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
@@ -208,6 +217,7 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
--mRefCnt; \
NS_LOG_RELEASE(this, mRefCnt, #_class); \
if (mRefCnt == 0) { \
+ mRefCnt = 1; /* stabilize */ \
NS_DELETEXPCOM(this); \
return 0; \
} \
diff --git a/mozilla/xpcom/components/nsXPComFactory.h b/mozilla/xpcom/components/nsXPComFactory.h
index 0354ae8b820..edc04fb1524 100644
--- a/mozilla/xpcom/components/nsXPComFactory.h
+++ b/mozilla/xpcom/components/nsXPComFactory.h
@@ -110,10 +110,7 @@ public: \
} \
\
protected: \
- virtual ~ns##_name##Factory() \
- { \
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction"); \
- } \
+ virtual ~ns##_name##Factory() {} \
}; \
NS_IMPL_ISUPPORTS1(ns##_name##Factory, nsIFactory);
diff --git a/mozilla/xpcom/glue/nsISupportsUtils.h b/mozilla/xpcom/glue/nsISupportsUtils.h
index 54aad2b905e..2c412701338 100644
--- a/mozilla/xpcom/glue/nsISupportsUtils.h
+++ b/mozilla/xpcom/glue/nsISupportsUtils.h
@@ -200,6 +200,15 @@ NS_IMETHODIMP_(nsrefcnt) _class::AddRef(void) \
/**
* Use this macro to implement the Release method for a given _class
* @param _class The name of the class implementing the method
+ *
+ * A note on the 'stabilization' of the refcnt to one. At that point,
+ * the object's refcount will have gone to zero. The object's
+ * destructor may trigger code that attempts to QueryInterface() and
+ * Release() 'this' again. Doing so will temporarily increment and
+ * decrement the refcount. (Only a logic error would make one try to
+ * keep a permanent hold on 'this'.) To prevent re-entering the
+ * destructor, we make sure that no balanced refcounting can return
+ * the refcount to |0|.
*/
#define NS_IMPL_RELEASE(_class) \
NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
@@ -208,6 +217,7 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release(void) \
--mRefCnt; \
NS_LOG_RELEASE(this, mRefCnt, #_class); \
if (mRefCnt == 0) { \
+ mRefCnt = 1; /* stabilize */ \
NS_DELETEXPCOM(this); \
return 0; \
} \
diff --git a/mozilla/xpcom/sample/nsSampleFactory.cpp b/mozilla/xpcom/sample/nsSampleFactory.cpp
index 94fe9c92b60..14bf56a5245 100644
--- a/mozilla/xpcom/sample/nsSampleFactory.cpp
+++ b/mozilla/xpcom/sample/nsSampleFactory.cpp
@@ -119,7 +119,6 @@ SampleFactoryImpl::SampleFactoryImpl(const nsCID &aClass,
SampleFactoryImpl::~SampleFactoryImpl()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
/**
diff --git a/mozilla/xpfe/apprunner/src/nsAppRunnerImpl.cpp b/mozilla/xpfe/apprunner/src/nsAppRunnerImpl.cpp
index a7459bb8f59..b6b3c894dd2 100644
--- a/mozilla/xpfe/apprunner/src/nsAppRunnerImpl.cpp
+++ b/mozilla/xpfe/apprunner/src/nsAppRunnerImpl.cpp
@@ -325,7 +325,6 @@ nsAppRunnerFactory::nsAppRunnerFactory() {
}
nsAppRunnerFactory::~nsAppRunnerFactory() {
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsAppRunnerFactory, kIFactoryIID);
diff --git a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp
index a78aab632cd..b164a7fa9f5 100644
--- a/mozilla/xpfe/appshell/src/nsCommandLineService.cpp
+++ b/mozilla/xpfe/appshell/src/nsCommandLineService.cpp
@@ -318,7 +318,6 @@ nsCmdLineServiceFactory::LockFactory(PRBool lock)
nsCmdLineServiceFactory::~nsCmdLineServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsCmdLineServiceFactory, kIFactoryIID);
diff --git a/mozilla/xpfe/appshell/src/nsFileLocations.cpp b/mozilla/xpfe/appshell/src/nsFileLocations.cpp
index 319c0711baa..54baf68e97f 100644
--- a/mozilla/xpfe/appshell/src/nsFileLocations.cpp
+++ b/mozilla/xpfe/appshell/src/nsFileLocations.cpp
@@ -628,7 +628,6 @@ nsresult nsFileLocatorFactory::LockFactory(PRBool /*lock*/)
nsFileLocatorFactory::~nsFileLocatorFactory()
//----------------------------------------------------------------------------------------
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsFileLocatorFactory, kIFactoryIID);
diff --git a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp
index 7c451becd7b..70c4402f5ab 100644
--- a/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp
+++ b/mozilla/xpfe/appshell/src/nsNetSupportDialog.cpp
@@ -841,7 +841,6 @@ nsNetSupportDialogFactory::LockFactory(PRBool lock)
nsNetSupportDialogFactory::~nsNetSupportDialogFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsNetSupportDialogFactory, kIFactoryIID);
diff --git a/mozilla/xpfe/appshell/src/nsSessionHistory.cpp b/mozilla/xpfe/appshell/src/nsSessionHistory.cpp
index 0c4c76ab3dd..e75875fd887 100644
--- a/mozilla/xpfe/appshell/src/nsSessionHistory.cpp
+++ b/mozilla/xpfe/appshell/src/nsSessionHistory.cpp
@@ -1508,7 +1508,6 @@ nsSessionHistoryFactory::LockFactory(PRBool aLock)
nsSessionHistoryFactory::~nsSessionHistoryFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsSessionHistoryFactory, kIFactoryIID);
diff --git a/mozilla/xpfe/components/prefwindow/src/nsPrefWindowFactory.cpp b/mozilla/xpfe/components/prefwindow/src/nsPrefWindowFactory.cpp
index 1c16cd57754..dba25cfd54f 100644
--- a/mozilla/xpfe/components/prefwindow/src/nsPrefWindowFactory.cpp
+++ b/mozilla/xpfe/components/prefwindow/src/nsPrefWindowFactory.cpp
@@ -73,7 +73,6 @@ nsPrefWindowFactory::nsPrefWindowFactory(
nsPrefWindowFactory::~nsPrefWindowFactory()
//----------------------------------------------------------------------------------------
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
// nsCRT::free(mClassName);
// nsCRT::free(mProgID);
}
diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp
index a78aab632cd..b164a7fa9f5 100644
--- a/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp
+++ b/mozilla/xpfe/components/startup/src/nsCommandLineService.cpp
@@ -318,7 +318,6 @@ nsCmdLineServiceFactory::LockFactory(PRBool lock)
nsCmdLineServiceFactory::~nsCmdLineServiceFactory()
{
- NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsCmdLineServiceFactory, kIFactoryIID);