Bug 16105. (Bugsplat 366256.) Ensure that nsISupports::Release() calls dtor only once by 'stabilizing' refcnt to a non-zero value before invoking the dtor. See also news://news.mozilla.org/37FD0F3C.3078AE5C%40netscape.com. r=scc,fur

This commit is contained in:
waterson%netscape.com 1999-10-12 03:05:10 +00:00
Родитель 89cce07489
Коммит c7347c6be0
46 изменённых файлов: 0 добавлений и 263 удалений

Просмотреть файл

@ -310,7 +310,6 @@ nsDocumentEncoderFactory::nsDocumentEncoderFactory()
nsDocumentEncoderFactory::~nsDocumentEncoderFactory()
{
MOZ_COUNT_DTOR(nsDocumentEncoderFactory);
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ADDREF(nsDocumentEncoderFactory)

Просмотреть файл

@ -625,7 +625,6 @@ nsDOMFactory::nsDOMFactory(const nsCID &aClass)
nsDOMFactory::~nsDOMFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsDOMFactory::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -1,212 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Mozilla Communicator client code.
*
* The Initial Developer of the Original Code is Netscape Communications
* Corporation. Portions created by Netscape are Copyright (C) 1998
* Netscape Communications Corporation. All Rights Reserved.
*/
#include "nsEditorShellFactory.h"
#include "nsEditorShell.h"
#include "nsEditor.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsXPComFactory.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_IID(kEditorShellCID, NS_EDITORSHELL_CID);
/////////////////////////////////////////////////////////////////////////
// nsEditorShellFactoryImpl
/////////////////////////////////////////////////////////////////////////
nsEditorShellFactoryImpl::nsEditorShellFactoryImpl(const nsCID &aClass,
const char* className,
const char* progID)
: mClassID(aClass), mClassName(className), mProgID(progID)
{
NS_INIT_REFCNT();
}
nsEditorShellFactoryImpl::~nsEditorShellFactoryImpl(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP
nsEditorShellFactoryImpl::QueryInterface(REFNSIID aIID,void** aInstancePtr)
{
if (aInstancePtr == NULL)
{
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID) )
{
*aInstancePtr = NS_STATIC_CAST(nsISupports*, this);
}
else if ( aIID.Equals(kIFactoryIID) )
{
*aInstancePtr = NS_STATIC_CAST(nsIFactory*, this);
}
if (*aInstancePtr == NULL)
{
return NS_ERROR_NO_INTERFACE;
}
AddRef();
return NS_OK;
}
NS_IMPL_ADDREF(nsEditorShellFactoryImpl)
NS_IMPL_RELEASE(nsEditorShellFactoryImpl)
NS_IMETHODIMP
nsEditorShellFactoryImpl::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
*aResult = NULL;
nsresult rv;
nsISupports *inst = nsnull;
if (mClassID.Equals(kEditorShellCID)) {
if (NS_FAILED(rv = NS_NewEditorShell((nsIEditorShell**) &inst)))
return rv;
}
else {
return NS_ERROR_NO_INTERFACE;
}
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
// We didn't get the right interface.
NS_ERROR("didn't support the interface you wanted");
}
NS_IF_RELEASE(inst);
return rv;
}
NS_IMETHODIMP
nsEditorShellFactoryImpl::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
nsresult
GetEditorShellFactory(nsIFactory **aFactory, const nsCID &aClass, const char *aClassName, const char *aProgID)
{
PR_EnterMonitor(GetEditorMonitor());
nsEditorShellFactoryImpl* factory = new nsEditorShellFactoryImpl(aClass, aClassName, aProgID);
if (!factory)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIFactory> pNSIFactory (do_QueryInterface(factory));
if (!pNSIFactory)
return NS_ERROR_NO_INTERFACE;
nsresult result = pNSIFactory->QueryInterface(kIFactoryIID,
(void **)aFactory);
PR_ExitMonitor(GetEditorMonitor());
return result;
}
//#define EDITOR_SHELL_STANDALONE
#if EDITOR_SHELL_STANDALONE
// return the proper factory to the caller
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char *aClassName,
const char *aProgID,
nsIFactory **aFactory)
{
if (! aFactory)
return NS_ERROR_NULL_POINTER;
nsEditorShellFactoryImpl* factory = new nsEditorShellFactoryImpl(aClass, aClassName, aProgID);
if (factory == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(factory);
*aFactory = factory;
return NS_OK;
}
extern "C" PR_IMPLEMENT(nsresult)
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->RegisterComponent(kEditorAppCoreCID,
"Editor Shell Component",
"component://netscape/editor/editorshell",
aPath, PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
extern "C" PR_IMPLEMENT(nsresult)
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kEditorAppCoreCID, aPath);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
#endif

Просмотреть файл

@ -56,7 +56,6 @@ nsTextServicesDocumentFactory::nsTextServicesDocumentFactory()
nsTextServicesDocumentFactory::~nsTextServicesDocumentFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ADDREF(nsTextServicesDocumentFactory)

Просмотреть файл

@ -61,7 +61,6 @@ nsTransactionManagerFactory::nsTransactionManagerFactory()
nsTransactionManagerFactory::~nsTransactionManagerFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ADDREF(nsTransactionManagerFactory)

Просмотреть файл

@ -56,7 +56,6 @@ nsTextServicesDocumentFactory::nsTextServicesDocumentFactory()
nsTextServicesDocumentFactory::~nsTextServicesDocumentFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ADDREF(nsTextServicesDocumentFactory)

Просмотреть файл

@ -74,7 +74,6 @@ bsConnectionFactory::bsConnectionFactory(const nsCID &aClass,
bsConnectionFactory::~bsConnectionFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -71,7 +71,6 @@ CookieViewerFactoryImpl::CookieViewerFactoryImpl(const nsCID &aClass,
CookieViewerFactoryImpl::~CookieViewerFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -71,7 +71,6 @@ WalletEditorFactoryImpl::WalletEditorFactoryImpl(const nsCID &aClass,
WalletEditorFactoryImpl::~WalletEditorFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -71,7 +71,6 @@ SignonViewerFactoryImpl::SignonViewerFactoryImpl(const nsCID &aClass,
SignonViewerFactoryImpl::~SignonViewerFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -71,7 +71,6 @@ WalletPreviewFactoryImpl::WalletPreviewFactoryImpl(const nsCID &aClass,
WalletPreviewFactoryImpl::~WalletPreviewFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -73,7 +73,6 @@ nsGfxFactoryBeOS::nsGfxFactoryBeOS(const nsCID &aClass)
nsGfxFactoryBeOS::~nsGfxFactoryBeOS()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryBeOS::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -78,7 +78,6 @@ nsGfxFactoryGTK::nsGfxFactoryGTK(const nsCID &aClass)
nsGfxFactoryGTK::~nsGfxFactoryGTK()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryGTK::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -71,7 +71,6 @@ nsGfxFactoryMac::nsGfxFactoryMac(const nsCID &aClass)
nsGfxFactoryMac::~nsGfxFactoryMac()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryMac::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -68,7 +68,6 @@ nsGfxFactoryMotif::nsGfxFactoryMotif(const nsCID &aClass)
nsGfxFactoryMotif::~nsGfxFactoryMotif()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryMotif::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -77,7 +77,6 @@ nsGfxFactoryOS2::nsGfxFactoryOS2( const nsCID &aClass)
nsGfxFactoryOS2::~nsGfxFactoryOS2()
{
NS_ASSERTION( mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsGfxFactoryOS2,nsIFactory::GetIID())

Просмотреть файл

@ -81,8 +81,6 @@ nsGfxFactoryPh::nsGfxFactoryPh(const nsCID &aClass)
nsGfxFactoryPh::~nsGfxFactoryPh()
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::~nsGfxFactoryPh Destructor\n"));
NS_ASSERTION(mRefCnt == 0, "nsGfxFactoryGTK::~nsGfxFactoryGTK non-zero refcnt at destruction");
}
nsresult nsGfxFactoryPh::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -55,7 +55,6 @@ nsGfxFactoryPS::nsGfxFactoryPS(const nsCID &aClass) :
nsGfxFactoryPS::~nsGfxFactoryPS()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsGfxFactoryPS, nsIFactory::GetIID())

Просмотреть файл

@ -90,7 +90,6 @@ nsGfxFactoryWin::nsGfxFactoryWin(const nsCID &aClass)
nsGfxFactoryWin::~nsGfxFactoryWin()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryWin::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -73,7 +73,6 @@ nsGfxFactoryXlib::nsGfxFactoryXlib(const nsCID &aClass)
nsGfxFactoryXlib::~nsGfxFactoryXlib()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryXlib::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -73,7 +73,6 @@ nsParserFactory::nsParserFactory(const nsCID &aClass)
nsParserFactory::~nsParserFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
nsHTMLEntities::ReleaseTable();
nsHTMLTags::ReleaseTable();
}

Просмотреть файл

@ -199,7 +199,6 @@ nsTextConverterFactory::nsTextConverterFactory(const nsCID &aClass,
nsTextConverterFactory::~nsTextConverterFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTextConverterFactory, NS_GET_IID(nsIFactory));

Просмотреть файл

@ -42,7 +42,6 @@ nsLocaleMacFactory::nsLocaleMacFactory(const nsCID &aClass)
nsLocaleMacFactory::~nsLocaleMacFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsLocaleMacFactory::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -43,7 +43,6 @@ nsLocaleUnixFactory::nsLocaleUnixFactory(const nsCID &aClass)
nsLocaleUnixFactory::~nsLocaleUnixFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsLocaleUnixFactory::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -42,7 +42,6 @@ nsLocaleWinFactory::nsLocaleWinFactory(const nsCID &aClass)
nsLocaleWinFactory::~nsLocaleWinFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsLocaleWinFactory::QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -310,7 +310,6 @@ nsDocumentEncoderFactory::nsDocumentEncoderFactory()
nsDocumentEncoderFactory::~nsDocumentEncoderFactory()
{
MOZ_COUNT_DTOR(nsDocumentEncoderFactory);
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ADDREF(nsDocumentEncoderFactory)

Просмотреть файл

@ -113,7 +113,6 @@ nsLayoutFactory::nsLayoutFactory(const nsCID &aClass)
nsLayoutFactory::~nsLayoutFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
#if 0
char* cs = mClassID.ToString();
printf("+++ Destroying layout factory for %s\n", cs);

Просмотреть файл

@ -94,7 +94,6 @@ nsAbFactory::nsAbFactory(const nsCID &aClass, const char* aClassName, const char
nsAbFactory::~nsAbFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
// NS_IF_RELEASE(mServiceManager);
PL_strfree(mClassName);
PL_strfree(mProgID);

Просмотреть файл

@ -88,7 +88,6 @@ nsOESettings::nsOESettings()
nsOESettings::~nsOESettings()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsOESettings, nsIImportSettings::GetIID());

Просмотреть файл

@ -77,7 +77,6 @@ nsMimeMiscStatusFactory::nsMimeMiscStatusFactory(const nsCID &aClass,
nsMimeMiscStatusFactory::~nsMimeMiscStatusFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
PL_strfree(mClassName);
PL_strfree(mProgID);
}

Просмотреть файл

@ -76,8 +76,6 @@ nsCalendarFactory::nsCalendarFactory(const nsCID &aClass,
nsCalendarFactory::~nsCalendarFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
NS_IF_RELEASE(mServiceManager);
PL_strfree(mClassName);
PL_strfree(mProgID);

Просмотреть файл

@ -76,8 +76,6 @@ nsVCardFactory::nsVCardFactory(const nsCID &aClass,
nsVCardFactory::~nsVCardFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
NS_IF_RELEASE(mServiceManager);
PL_strfree(mClassName);
PL_strfree(mProgID);

Просмотреть файл

@ -78,7 +78,6 @@ nsMimeEmitterFactory::nsMimeEmitterFactory(const nsCID &aClass,
nsMimeEmitterFactory::~nsMimeEmitterFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
PL_strfree(mClassName);
PL_strfree(mProgID);
}

Просмотреть файл

@ -91,7 +91,6 @@ nsMimeFactory::nsMimeFactory(const nsCID &aClass)
nsMimeFactory::~nsMimeFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsMimeFactory::QueryInterface(const nsIID &aIID, void **aResult)

Просмотреть файл

@ -89,8 +89,6 @@ nsMsgNewsFactory::nsMsgNewsFactory(const nsCID &aClass,
nsMsgNewsFactory::~nsMsgNewsFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
PL_strfree(mClassName);
PL_strfree(mProgID);
}

Просмотреть файл

@ -51,7 +51,6 @@ GIFDecoder::GIFDecoder(il_container* aContainer)
GIFDecoder::~GIFDecoder(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
};
NS_IMETHODIMP

Просмотреть файл

@ -54,7 +54,6 @@ JPGDecoder::JPGDecoder(il_container* aContainer)
JPGDecoder::~JPGDecoder(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
};

Просмотреть файл

@ -54,7 +54,6 @@ PNGDecoder::PNGDecoder(il_container* aContainer)
PNGDecoder::~PNGDecoder(void)
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
};
static NS_DEFINE_IID(kPNGDecoderIID, NS_PNGDECODER_IID);

Просмотреть файл

@ -63,7 +63,6 @@ ImgFactoryImpl::ImgFactoryImpl(const nsCID &aClass,
ImgFactoryImpl::~ImgFactoryImpl()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMETHODIMP

Просмотреть файл

@ -68,7 +68,6 @@ nsPluginFactory :: nsPluginFactory(const nsCID &aClass, nsIServiceManager* servi
nsPluginFactory :: ~nsPluginFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsPluginFactory :: QueryInterface(const nsIID &aIID,

Просмотреть файл

@ -68,7 +68,6 @@ nsPluginFactory :: nsPluginFactory(const nsCID &aClass, nsIServiceManager* servi
nsPluginFactory :: ~nsPluginFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsPluginFactory :: QueryInterface(const nsIID &aIID,

1
netwerk/cache/mgr/nsCacheManager.cpp поставляемый
Просмотреть файл

@ -551,7 +551,6 @@ nsCacheManagerFactory::nsCacheManagerFactory( )
nsCacheManagerFactory::~nsCacheManagerFactory( )
{
NS_ASSERTION(mRefCnt == 0, "Wrong ref count") ;
PR_AtomicDecrement(&gInstanceCnt) ;
}

2
netwerk/cache/obj/nsCacheObject.cpp поставляемый
Просмотреть файл

@ -216,7 +216,6 @@ nsCacheObject::~nsCacheObject()
if (m_pStream)
delete m_pStream;
NS_ASSERTION(mRefCnt == 0, "wrong ref count") ;
PR_AtomicDecrement(&gInstanceCnt) ;
}
@ -733,7 +732,6 @@ nsCacheObjectFactory::nsCacheObjectFactory ()
nsCacheObjectFactory::~nsCacheObjectFactory ()
{
NS_ASSERTION(mRefCnt == 0,"Wrong ref count");
PR_AtomicDecrement(&gInstanceCnt);
}

2
netwerk/cache/pref/nsCachePref.cpp поставляемый
Просмотреть файл

@ -100,7 +100,6 @@ nsCachePref::~nsCachePref()
m_DiskCacheFolder = 0;
}
NS_ASSERTION(mRefCnt == 0, "Wrong ref count") ;
PR_AtomicDecrement(&gInstanceCnt) ;
}
@ -318,7 +317,6 @@ nsCachePrefFactory::nsCachePrefFactory ()
nsCachePrefFactory::~nsCachePrefFactory ()
{
NS_ASSERTION(mRefCnt == 0,"Wrong ref count");
PR_AtomicDecrement(&gInstanceCnt);
}

Просмотреть файл

@ -73,7 +73,6 @@ nsParserFactory::nsParserFactory(const nsCID &aClass)
nsParserFactory::~nsParserFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
nsHTMLEntities::ReleaseTable();
nsHTMLTags::ReleaseTable();
}

Просмотреть файл

@ -199,7 +199,6 @@ nsTextConverterFactory::nsTextConverterFactory(const nsCID &aClass,
nsTextConverterFactory::~nsTextConverterFactory()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
NS_IMPL_ISUPPORTS(nsTextConverterFactory, NS_GET_IID(nsIFactory));