Bug 383939. All RDF datasources must implement cycle collection to avoid leaking. r/sr=bsmedberg

This commit is contained in:
sayrer%gmail.com 2008-01-23 20:52:57 +00:00
Родитель 0e594828a8
Коммит 938920c59d
4 изменённых файлов: 32 добавлений и 52 удалений

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

@ -347,6 +347,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULDocument, nsXMLDocument)
} }
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTooltipNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTooltipNode)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLocalStore)
if (tmp->mOverlayLoadObservers.IsInitialized()) if (tmp->mOverlayLoadObservers.IsInitialized())
tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb); tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb);

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

@ -251,7 +251,12 @@ FileSystemDataSource::Create(nsISupports* aOuter, const nsIID& aIID, void **aRes
return self->QueryInterface(aIID, aResult); return self->QueryInterface(aIID, aResult);
} }
NS_IMPL_ISUPPORTS1(FileSystemDataSource, nsIRDFDataSource) NS_IMPL_CYCLE_COLLECTION_0(FileSystemDataSource)
NS_IMPL_CYCLE_COLLECTING_ADDREF(FileSystemDataSource)
NS_IMPL_CYCLE_COLLECTING_RELEASE(FileSystemDataSource)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FileSystemDataSource)
NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_INTERFACE_MAP_END
NS_IMETHODIMP NS_IMETHODIMP
FileSystemDataSource::GetURI(char **uri) FileSystemDataSource::GetURI(char **uri)

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

@ -46,6 +46,7 @@
#include "nsISupportsArray.h" #include "nsISupportsArray.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h" #include "nsString.h"
#include "nsCycleCollectionParticipant.h"
#if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN) || defined(XP_BEOS) #if defined(XP_UNIX) || defined(XP_OS2) || defined(XP_WIN) || defined(XP_BEOS)
#define USE_NC_EXTENSION #define USE_NC_EXTENSION
@ -54,7 +55,8 @@
class FileSystemDataSource : public nsIRDFDataSource class FileSystemDataSource : public nsIRDFDataSource
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(FileSystemDataSource)
NS_DECL_NSIRDFDATASOURCE NS_DECL_NSIRDFDATASOURCE
static NS_METHOD Create(nsISupports* aOuter, static NS_METHOD Create(nsISupports* aOuter,

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

@ -66,6 +66,7 @@
#include "nsCRTGlue.h" #include "nsCRTGlue.h"
#include "nsCRT.h" #include "nsCRT.h"
#include "nsEnumeratorUtils.h" #include "nsEnumeratorUtils.h"
#include "nsCycleCollectionParticipant.h"
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -91,7 +92,8 @@ protected:
public: public:
// nsISupports interface // nsISupports interface
NS_DECL_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
// nsILocalStore interface // nsILocalStore interface
@ -264,51 +266,21 @@ NS_NewLocalStore(nsISupports* aOuter, REFNSIID aIID, void** aResult)
return rv; return rv;
} }
NS_IMPL_CYCLE_COLLECTION_1(LocalStoreImpl, mInner)
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS(LocalStoreImpl, nsILocalStore)
// nsISupports interface NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(LocalStoreImpl)
NS_INTERFACE_MAP_ENTRY(nsILocalStore)
NS_IMPL_ADDREF(LocalStoreImpl) NS_INTERFACE_MAP_ENTRY(nsIRDFDataSource)
NS_IMPL_RELEASE(LocalStoreImpl) NS_INTERFACE_MAP_ENTRY(nsIRDFRemoteDataSource)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_IMETHODIMP NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
LocalStoreImpl::QueryInterface(REFNSIID aIID, void** aResult) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsILocalStore)
{ NS_INTERFACE_MAP_END
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
NS_PRECONDITION(aResult != nsnull, "null ptr");
if (! aResult)
return NS_ERROR_NULL_POINTER;
if (aIID.Equals(kISupportsIID) ||
aIID.Equals(NS_GET_IID(nsILocalStore))) {
*aResult = static_cast<nsILocalStore*>(this);
}
else if (aIID.Equals(NS_GET_IID(nsIRDFDataSource))) {
*aResult = static_cast<nsIRDFDataSource *>(this);
}
else if (aIID.Equals(NS_GET_IID(nsIRDFRemoteDataSource))) {
*aResult = static_cast<nsIRDFRemoteDataSource *>(this);
}
else if (aIID.Equals(NS_GET_IID(nsIObserver))) {
*aResult = static_cast<nsIObserver *>(this);
}
else if (aIID.Equals(NS_GET_IID(nsISupportsWeakReference))) {
*aResult = static_cast<nsISupportsWeakReference *>(this);
}
else {
*aResult = nsnull;
return NS_NOINTERFACE;
}
NS_ADDREF(this);
return NS_OK;
}
// nsILocalStore interface // nsILocalStore interface
// nsIRDFDataSource interface // nsIRDFDataSource interface
NS_IMETHODIMP NS_IMETHODIMP