diff --git a/content/xul/templates/src/nsXULTemplateBuilder.cpp b/content/xul/templates/src/nsXULTemplateBuilder.cpp index b8f304cc51ca..487f77569c42 100644 --- a/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -215,7 +215,10 @@ static const char kRDFNameSpaceURI[] RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) { NS_IF_RELEASE(mRoot); - NS_IF_RELEASE(mDB); + if (mDB) { + mDB->RemoveObserver(this); + NS_RELEASE(mDB); + } // NS_IF_RELEASE(mDocument) not refcounted --gRefCnt; @@ -304,6 +307,8 @@ RDFGenericBuilderImpl::SetDataBase(nsIRDFCompositeDataSource* aDataBase) mDB = aDataBase; NS_ADDREF(mDB); + + mDB->AddObserver(this); return NS_OK; } diff --git a/rdf/content/src/nsRDFGenericBuilder.cpp b/rdf/content/src/nsRDFGenericBuilder.cpp index b8f304cc51ca..487f77569c42 100644 --- a/rdf/content/src/nsRDFGenericBuilder.cpp +++ b/rdf/content/src/nsRDFGenericBuilder.cpp @@ -215,7 +215,10 @@ static const char kRDFNameSpaceURI[] RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) { NS_IF_RELEASE(mRoot); - NS_IF_RELEASE(mDB); + if (mDB) { + mDB->RemoveObserver(this); + NS_RELEASE(mDB); + } // NS_IF_RELEASE(mDocument) not refcounted --gRefCnt; @@ -304,6 +307,8 @@ RDFGenericBuilderImpl::SetDataBase(nsIRDFCompositeDataSource* aDataBase) mDB = aDataBase; NS_ADDREF(mDB); + + mDB->AddObserver(this); return NS_OK; } diff --git a/rdf/content/src/nsXULTemplateBuilder.cpp b/rdf/content/src/nsXULTemplateBuilder.cpp index b8f304cc51ca..487f77569c42 100644 --- a/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/rdf/content/src/nsXULTemplateBuilder.cpp @@ -215,7 +215,10 @@ static const char kRDFNameSpaceURI[] RDFGenericBuilderImpl::~RDFGenericBuilderImpl(void) { NS_IF_RELEASE(mRoot); - NS_IF_RELEASE(mDB); + if (mDB) { + mDB->RemoveObserver(this); + NS_RELEASE(mDB); + } // NS_IF_RELEASE(mDocument) not refcounted --gRefCnt; @@ -304,6 +307,8 @@ RDFGenericBuilderImpl::SetDataBase(nsIRDFCompositeDataSource* aDataBase) mDB = aDataBase; NS_ADDREF(mDB); + + mDB->AddObserver(this); return NS_OK; }